CrossClj

2.1.12 docs

SourceDocs



RECENT
    VARS
    !!
    !>
    ->Ova
    <<
    add-internal-watch
    append!
    clone
    concat!
    delete-indices
    delete-internal-objs
    delete-internal-watches
    empty!
    filter!
    get-filtered
    has?
    indices
    init!
    insert!
    insert-fn
    internal-watch-fn
    map!
    map-indexed!
    ova
    ova-state
    remove!
    remove-internal-watch
    reverse!
    select
    selectv
    smap!
    smap-indexed!
    sort!
    split
    standardise-opts

    « Index of all namespaces of this project

    (!! ova pchk val)
    sets the value of a given data cell in the ova
    (dosync (-> (range 5) (ova) (!! 1 0) persistent!))
    => [0 0 2 3 4]
    (dosync (-> (range 5) (ova) (!! #{1 2} 0) persistent!))
    => [0 0 0 3 4]
    (dosync (-> (range 5) (ova) (!! even? 0) persistent!))
    => [0 1 0 3 0]
    macro
    (!> ova pchk & forms)
    applies a set of transformations to a selector on the ova
    (let [ov (ova [{:id :1}])]
    
      (dosync (!> ov 0
                  (assoc-in [:a :b] 1)
                  (update-in [:a :b] inc)
                  (assoc :c 3)))
      (<< ov))
    => [{:id :1 :c 3 :a {:b 2}}]
    (->Ova state)
    Positional factory function for class hara.ova.Ova.
    
    macro
    (<< & forms)
    outputs the persistent value of an entire body after manipulation
    (<< (def obj-a (ova [1 2 3 4 5]))
        (append! obj-a 6 7 8 9))
    => [1 2 3 4 5 6 7 8 9]
    Private
    (add-internal-watch ova irf)
    (append! ova & es)
    like conj! but appends multiple array elements to the ova
    
    (let [o (ova [{:id :1 :val 1}])]
      (dosync (append! o {:id :2 :val 1} {:id :3 :val 2}))
      (persistent! o))
    => [{:id :1 :val 1} {:id :2 :val 1} {:id :3 :val 2}]
    (clone old)
    creates an exact copy of the ova, including its watches
    (let [o (ova (range 10))
          _ (watch/set o {:a (fn [_ _ _ _ _])})
          o-clone (clone o)]
      (persistent! o-clone) => (range 10)
      (watch/list o-clone) => (just {:a fn?}))
    (concat! ova es & more)
    works like clojure.core/concat, but modifies ova state
    
    (let [o1 (ova [{:id :1 :val 1} {:id :2 :val 1}])
          o2 (ova [{:id :3 :val 2}])
          arr [{:id :4 :val 2}]]
      (dosync (concat! o1 o2 arr))
      (persistent! o1))
    => [{:val 1, :id :1} {:val 1, :id :2}
        {:val 2, :id :3} {:val 2, :id :4}]
    (delete-indices ova idx)
    Private
    (delete-internal-objs ova indices)
    Private
    (delete-internal-watches ova idx)
    (empty! ova)
    (filter! ova pchk)
    filter is the opposite of reverse. It keeps the
    elements that matches a selector instead of throwing
    them away
    
    (let [o (ova (range 10))]
      (dosync (filter! o odd?))
      (persistent! o))
    => [1 3 5 7 9]
    
    (let [o (ova (range 10))]
      (dosync (filter! o #{'(< 3) '(> 6)}))
      (persistent! o))
    => [0 1 2 7 8 9]
    (get-filtered ova k sel nv)
    gets the first element in the ova that matches the selector:
    
    (let [o (ova [{:id :1 :val 1} {:id :2 :val 1}])]
      (get-filtered o :1 nil nil)
      => {:val 1, :id :1}
    
      (get-filtered o :2 nil nil)
      => {:val 1, :id :2}
    
      (get-filtered o :3 nil :not-found)
      => :not-found)
    (has? ova)(has? ova pchk)
    checks that the ova contains elements matching a selector
    
    (let [o (ova [{:id :1 :val 1} {:id :2 :val 1}
                  {:id :3 :val 2} {:id :4 :val 2}])]
    
      (has? o) => true
      (has? o 0) => true
      (has? o -1) => false
      (has? o [:id '((name) (bigint) (odd?))]) => true)
    (indices ova)(indices ova pchk)
    provides intuitive filtering functionality of ova elements, outputting valid indices
    
    (let [o (ova [{:id :1 :val 1} {:id :2 :val 1}
                  {:id :3 :val 2} {:id :4 :val 2}])]
      (indices o) => [0 1 2 3]
      (indices o 0) => [0]
      (indices o [:val 1]) => [0 1]
      (indices o [:val even?]) => [2 3]
      (indices o [:val even? '(:id (name) (bigint)) odd?]) => [2])
    
    
    (init! ova)(init! ova coll)
    re-initialises the ova to either an empty array or the second argumentcoll
    
    (let [o (ova [])]
      (dosync (init! o [{:id :1 :val 1} {:id :2 :val 1}]))
      (persistent! o))
    => [{:val 1, :id :1} {:val 1, :id :2}]
    (insert! ova val & [i])
    inserts data at either the end of the ova or when given an index
    
    (let [o (ova (range 5))]
      (dosync (insert! o 6))
      (dosync (insert! o 5 5))
      (persistent! o))
    => [0 1 2 3 4 5 6]
    (insert-fn v val & [i])
    Private
    (internal-watch-fn ova)
    (map! ova f & args)
    applies a function on the ova with relevent arguments
    
    (let [o (ova [{:id :1} {:id :2}])]
      (dosync (map! o assoc :val 1))
      (persistent! o))
    => [{:val 1, :id :1} {:val 1, :id :2}]
    (map-indexed! ova f)
    applies a function that taking the data index as well as the data
    to all elements of the ova
    
    (let [o (ova [{:id :1} {:id :2}])]
      (dosync (map-indexed! o (fn [i m]
                                (assoc m :val i))))
      (persistent! o))
    => [{:val 0, :id :1} {:val 1, :id :2}]
    (ova)(ova coll)
    constructs an ova instance
    
    (ova []) ;=> #ova []
    (ova [1 2 3]) ;=>  #ova [1 2 3]
    (ova [{:id :1} {:id :2}]) ;=> #ova [{:id :1} {:id :2}]
    
    Private
    (ova-state)
    (remove! ova pchk)
    removes data from the ova that matches a selector
    
    (let [o (ova (range 10))]
      (dosync (remove! o odd?))
      (persistent! o))
    => [0 2 4 6 8]
    
    (let [o (ova (range 10))]
      (dosync (remove! o '(not= 3)))
      (persistent! o))
    => [3]
    
    (let [o (ova (range 10))]
      (dosync (remove! o #{'(< 3) '(> 6)}))
      (persistent! o))
    => [3 4 5 6]
    Private
    (remove-internal-watch ova irf)
    (reverse! ova)
    reverses the order of elements in the ova
    (let [o (ova (range 5))]
      (dosync (reverse! o))
      (persistent! o) => [4 3 2 1 0])
    (select ova)(select ova pchk)
    grabs the selected ova entries as a set of values
    
    (let [o (ova [{:id :1 :val 1} {:id :2 :val 1}
                  {:id :3 :val 2} {:id :4 :val 2}])]
    
      (select o) => #{{:id :1, :val 1} {:id :2, :val 1} {:id :3, :val 2} {:id :4, :val 2}}
      (select o 0) => #{{:id :1 :val 1}}
      (select o #{1 2}) => #{{:id :2 :val 1} {:id :3 :val 2}}
      (select o #(even? (:val %))) => #{{:id :3 :val 2} {:id :4 :val 2}}
      (select o [:val 1]) => #{{:id :1 :val 1} {:id :2 :val 1}}
      (select o [:val even?]) => #{{:id :3 :val 2} {:id :4 :val 2}}
      (select o #{[:id :1] [:val 2]})
      => #{{:id :1 :val 1} {:id :3 :val 2} {:id :4 :val 2}}
      (select o [:id '((name) (bigint) (odd?))])
      => #{{:id :1 :val 1} {:id :3 :val 2}})
    (selectv ova)(selectv ova pchk)
    (smap! ova pchk f & args)
    applies a function to only selected elements of the array
    
    (let [o (ova [{:id :1 :val 1} {:id :2 :val 1}
                  {:id :3 :val 2} {:id :4 :val 2}])]
      (dosync (smap! o [:val 1]
                     update-in [:val] #(+ % 100)))
      (persistent! o))
    => [{:val 101, :id :1} {:val 101, :id :2} {:val 2, :id :3} {:val 2, :id :4}]
    (smap-indexed! ova pchk f)
    applies a function that taking the data index as well as the data
    to selected elements of the ova
    
    (let [o (ova [{:id :1 :val 1} {:id :2 :val 1}
                  {:id :3 :val 2} {:id :4 :val 2}])]
      (dosync (smap-indexed! o [:val 1]
                             (fn [i m]
                               (update-in m [:val] #(+ i 100 %)))))
      (persistent! o))
    => [{:val 101, :id :1} {:val 102, :id :2} {:val 2, :id :3} {:val 2, :id :4}]
    (sort! ova)(sort! ova comp)(sort! ova sel comp)
    sorts all data in the ova using a comparator function
    
    (let [o (ova [2 1 3 4 0])]
      (dosync (sort! o >))
      (persistent! o) => [4 3 2 1 0]
    
      (dosync (sort! o <))
      (persistent! o) => [0 1 2 3 4])
    (split ova pchk)
    creates an exact copy of the ova, including its watches
    (let [o (ova (range 10))
          sp (dosync (split o #{'(< 3) '(> 6)}))]
      (persistent! (sp true))  => [0 1 2 7 8 9]
      (persistent! (sp false)) => [3 4 5 6])
    Private
    (standardise-opts opts)