Liking cljdoc? Tell your friends :D

framed.std.core

Utility functions to complement clojure.core

Utility functions to complement clojure.core
raw docstring

coll-wrapclj/s

(coll-wrap x-or-xs)

Wrap value in a vector if it is not sequential already Ex: (coll-wrap 2) ; => [2] (coll-wrap [1 2 3]) ; => [1 2 3]

Wrap value in a vector if it is not sequential already
Ex:
  (coll-wrap 2)       ; => [2]
  (coll-wrap [1 2 3]) ; => [1 2 3]
sourceraw docstring

findclj/s

(find pred coll)

Return the first value of x in coll that is logically true for (pred x) Similar to clojure.core/some, but returns the item itself.

Ex: (find even? [1 1 1 3 4 5 6]) ; => 4

Return the first value of x in coll that is logically true for (pred x)
Similar to clojure.core/some, but returns the item itself.

Ex: (find even? [1 1 1 3 4 5 6]) ; => 4
sourceraw docstring

flipclj/s

(flip f)
(flip f y x)

Takes two arguments in the reverse order of f ('flips' a function of two arguments) If supplied a function with no args, returns a new function accepting the reversed args

Ex: (flip dissoc :foo {:foo 1 :bar 2}) ; => {:bar 2}

(def flipped-dissoc (flip dissoc)) (flipped-dissoc :foo {:foo 1 :bar 2}) ; => {:bar 2}

Takes two arguments in the reverse order of f ('flips' a function
of two arguments)
If supplied a function with no args, returns a new function
accepting the reversed args

Ex:
  (flip dissoc :foo {:foo 1 :bar 2})
  ; => {:bar 2}

  (def flipped-dissoc (flip dissoc))
  (flipped-dissoc :foo {:foo 1 :bar 2})
  ; => {:bar 2}
sourceraw docstring

from-ednclj/s

(from-edn x)

Attempt to parse x as EDN, or return nil on failure

Attempt to parse x as EDN, or return nil on failure
sourceraw docstring

future-loopcljmacro

(future-loop & body)

Execute body repeatedly within a future, returning the future

Execute body repeatedly within a future, returning the future
sourceraw docstring

map-from-keysclj/smacro

(map-from-keys & forms)

Given symbols, e.g. (map-from-keys foo bar), return a map with those names as keyword keys, and those values:

Ex: (map-from-keys foo bar) ; => {:foo foo :bar bar}

Given symbols, e.g. `(map-from-keys foo bar)`,
return a map with those names as keyword keys, and those values:

Ex:
  (map-from-keys foo bar)
  ; => {:foo foo
        :bar bar}
sourceraw docstring

map-kvclj/s

(map-kv val-fn coll)
(map-kv key-fn val-fn coll)

Same as map-tup but returns results in a map

Same as `map-tup` but returns results in a map
sourceraw docstring

map-tupclj/s

(map-tup val-fn coll)
(map-tup key-fn val-fn coll)

For all k,v in coll, return a seq of [(key-fn k) (val-fn v)] tuples

Ex: (map-tup #(* 2 %) #(* 3 %) {1 2, 3 4, 5 6}) ; => ([2 6] [6 12] [10 18])

For all k,v in coll, return a seq of [(key-fn k) (val-fn v)] tuples

Ex:
  (map-tup #(* 2 %) #(* 3 %) {1 2, 3 4, 5 6})
  ; => ([2 6] [6 12] [10 18])
sourceraw docstring

mapcatclj/s

(mapcat f coll)

Like clojure.core/mapcat over a single coll without object reachability memory issues. This is especially useful when large seqs are generated by f, but this is a general-purpose replacement for its clojure.core counterpart.

See http://clojurian.blogspot.com/2012/11/beware-of-mapcat.html http://stackoverflow.com/questions/21943577/mapcat-breaking-the-lazyness

Like clojure.core/mapcat over a single coll without object
reachability memory issues. This is especially useful when
large seqs are generated by f, but this is a general-purpose
replacement for its clojure.core counterpart.

See http://clojurian.blogspot.com/2012/11/beware-of-mapcat.html
    http://stackoverflow.com/questions/21943577/mapcat-breaking-the-lazyness
sourceraw docstring

rand-alphanumericclj/s

(rand-alphanumeric len)

Generate a string of random letters/digits of a given length

Generate a string of random letters/digits of a given length
sourceraw docstring

rand-int-betweenclj/s

(rand-int-between min-val max-val)

Generate a random int in the inclusive range of min-val to max-val

Generate a random int in the inclusive range of min-val to max-val
sourceraw docstring

shuffleclj

(shuffle rng coll)

Same as clojure.core/shuffle but accepts source of randomness for deterministic testing

Same as clojure.core/shuffle but accepts source of randomness
for deterministic testing
sourceraw docstring

to-ednclj/s

(to-edn x)

pr-str x only if it is truthy, else return nil

pr-str x only if it is truthy, else return nil
sourceraw docstring

when-assocclj/s

(when-assoc coll k v)

When v is truthy, assoc it into coll at k. Otherwise return coll

When v is truthy, assoc it into coll at k. Otherwise return coll
sourceraw docstring

when-assoc-inclj/s

(when-assoc-in coll ks v)

When v is truthy, assoc it into coll at ks. Otherwise return coll

When v is truthy, assoc it into coll at ks. Otherwise return coll
sourceraw docstring

zipclj/s

(zip & colls)

Zip corresponding elements from two or more colls together Ex: (zip [1 2] [3 4]) ; => [[1 3] [2 4]]

Zip corresponding elements from two or more colls together
Ex:
  (zip [1 2] [3 4])
  ; => [[1 3] [2 4]]
sourceraw docstring

zipmap-seqclj/s

(zipmap-seq key-fn val-fn coll)

Given a collection coll, return a map where for all k in coll, key of entry is (f k) and value of entry is (g k)

Ex: (zipmap-seq #(* 2 %) (* 3 %) [1 2 3]) ;=> {2 3, 4 6, 6 9}

Given a collection `coll`, return a map where for all k in coll,
key of entry is (f k) and value of entry is (g k)

Ex:
  (zipmap-seq #(* 2 %) (* 3 %) [1 2 3])
  ;=> {2 3, 4 6, 6 9}
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close