Search code examples
clojureanglican

Accessing a list in a defquery


This may be a pretty basic question but I could not find answer elsewhere. I have a list that contains only numbers.

(def data [1 2.3 4.3 5.6 5.3 2.4])

I write the following defquery to uniformly sample from this list data

(defquery pois [data1]
  (let [days (sample 
              (uniform-discrete 1 6))          
    day1 ((nth data1 days))
      ]
    day1))

and try to get samples using

(def samples 
  (take 100
        (doquery :importance pois [data])))

(first samples)

I tried passing data to the defquery pois but still no luck. Any ideas on how to achieve this? Thanks in advance.


Solution

  • I understand that this may not be the right platform for this but nevertheless for clojing this question..here how I was able to solve it.

    (defquery pois [data1]
      (let [days (sample 
                  (uniform-discrete 1 6))          
        day1 ((nth data1 days))
          ]
        day1))
    
    (def samples 
      (take 10000
            (doquery :importance pois [data])))
    
    (first samples)