Liking cljdoc? Tell your friends :D

yang.lang


and->clj

(and->)
(and-> x)
(and-> x & [f & fs])
source

append-if-absentclj

(append-if-absent v xs)
(append-if-absent v xs delim)
source

bbuffer->strclj

(bbuffer->str bb)
source

bytes->strclj

(bytes->str bs)
(bytes->str bs enc)
source

camel-to-dashclj

(camel-to-dash k)
source

capitalizeclj

(capitalize xs)
source

cconjclj

(cconj xs item & {:keys [size]})

circular conj adds an item into a collection, droping the last element in case a collection count is greater than a :size. (def l '(10 11 12 13 14 15 16 17)) (take 5 (iterate #(cconj % (rand-int 10) :size 10) l)) => ((10 11 12 13 14 15 16 17) (3 10 11 12 13 14 15 16 17) (9 3 10 11 12 13 14 15 16 17) (5 9 3 10 11 12 13 14 15 16) (2 5 9 3 10 11 12 13 14 15))

circular conj
adds an item into a collection, droping the last element
in case a collection count is greater than a :size.
(def l '(10 11 12 13 14 15 16 17))
(take 5 (iterate #(cconj % (rand-int 10) :size 10) l))
=>
((10 11 12 13 14 15 16 17)
 (3 10 11 12 13 14 15 16 17)
 (9 3 10 11 12 13 14 15 16 17)
 (5 9 3 10 11 12 13 14 15 16)
 (2 5 9 3 10 11 12 13 14 15))
sourceraw docstring

csv->vecclj

(csv->vec csv)
source

dash-keysclj

(dash-keys m)
(dash-keys from m)
source

dash-to-camelclj

(dash-to-camel xs)
source

deep-merge-withclj

(deep-merge-with f & maps)

like merge-with, but merges maps recursively, appling the given fn only when there's a non-map at a particular level. (deepmerge + {:a {:b {:c 1 :d {:x 1 :y 2}} :e 3} :f 4} {:a {:b {:c 2 :d {:z 9} :z 3} :e 100}}) -> {:a {:b {:z 3, :c 3, :d {:z 9, :x 1, :y 2}}, :e 103}, :f 4}

like merge-with, but merges maps recursively, appling the given fn
only when there's a non-map at a particular level.
(deepmerge + {:a {:b {:c 1 :d {:x 1 :y 2}} :e 3} :f 4}
             {:a {:b {:c 2 :d {:z 9} :z 3} :e 100}})
-> {:a {:b {:z 3, :c 3, :d {:z 9, :x 1, :y 2}}, :e 103}, :f 4}
sourceraw docstring

dissoc-inclj

(dissoc-in m [k & ks :as keys])

from https://github.com/clojure/core.incubator

dissociates an entry from a nested associative structure returning a new nested structure. keys is a sequence of keys. Any empty maps that result will not be present in the new structure.

from https://github.com/clojure/core.incubator

dissociates an entry from a nested associative structure returning a new
nested structure. keys is a sequence of keys. Any empty maps that result
will not be present in the new structure.
sourceraw docstring

edn-resourceclj

(edn-resource path)
source

extract-key-nsclj

(extract-key-ns m kns)

=> (extract-key-ns {:a/one :a-one :a/two :a-two :b/one :b-one :b/two :b-two} :a)

{:a {:one :a-one :two :a-two}}

=> (extract-key-ns {:a/one :a-one :a/two :a-two :b/one :b-one :b/two :b-two}
                :a)

{:a {:one :a-one
     :two :a-two}}
sourceraw docstring

filter-kvclj

(filter-kv m f)

Takes a map, filters on (f k v) for each map entry, returns a map.

Takes a map, filters on (f k v) for each map entry, returns a map.
sourceraw docstring

fmkclj

(fmk m f)

apply f to each key k of map m

apply f to each key k of map m
sourceraw docstring

fmvclj

(fmv m f)

apply f to each value v of map m

apply f to each value v of map m
sourceraw docstring

freq-mapclj

(freq-map m by)
source

future->completable-futureclj

(future->completable-future fut pool)
source

group-by-firstclj

(group-by-first m)

takes a seq of 2 element tuples and groups them by the first (key) element. (group-by-first [[1 2][1 4][2 3][2 7]]) {1 (4 2), 2 (7 3)}

takes a seq of 2 element tuples
and groups them by the first (key) element.
 (group-by-first [[1 2][1 4][2 3][2 7]])
   {1 (4 2), 2 (7 3)}
sourceraw docstring

group-by-nsclj

(group-by-ns m)

=> (group-by-ns {:a/one :a-one :b/one :b-one :a/two :a-two :b/two :b-two})

{:a {:one :a-one, :two :a-two} :b {:one :b-one, :two :b-two}}

=> (group-by-ns {:a/one :a-one :b/one :b-one :a/two :a-two :b/two :b-two})

{:a {:one :a-one, :two :a-two}
 :b {:one :b-one, :two :b-two}}
sourceraw docstring

gunzip-ednclj

(gunzip-edn bs)
source

gzip-ednclj

(gzip-edn edn)
source

index-byclj

(index-by by xs)

given a sequence of maps index them by the key

(!) duplicate/nil keys: latest wins (!)

=> (index [{:a 123, :b "first"} {:a 234, :b "second"} {:a 345, :b "third"}] ;; seq of maps :a) ;; key to index by

{123 {:a 123, :b "first"}, 234 {:a 234, :b "second"}, 345 {:a 345, :b "third"}}

given a sequence of maps
index them by the key

(!) duplicate/nil keys: latest wins (!)

=> (index [{:a 123, :b "first"}
           {:a 234, :b "second"}
           {:a 345, :b "third"}]  ;; seq of maps
           :a)                      ;; key to index by

   {123 {:a 123, :b "first"},
    234 {:a 234, :b "second"},
    345 {:a 345, :b "third"}}
sourceraw docstring

instance-methodclj

(instance-method obj method-name)
(instance-method obj method-name args)
source

jcoll?clj

(jcoll? x)
source

joinclj

(join xs1 xs2 on)
source

lower-caseclj

(lower-case s)
source

map->keys-as-pathclj

(map->keys-as-path m)
(map->keys-as-path m path)

Takes a nested map and returns a flat map where each key is the path of the original map. => (map->path-keys {:a {:b 'abc'}}) {[:a :b] 'abc'}

Takes a nested map and returns a flat map where each key is the path of the original map.
=> (map->path-keys {:a {:b 'abc'}})
{[:a :b] 'abc'}
sourceraw docstring

merge-mapsclj

(merge-maps & m)
source

none?clj

(none? v)
source

one-if-noneclj

(one-if-none n)
source

parse-doubleclj

(parse-double d)
source

parse-longclj

(parse-long l)
source

parse-numberclj

(parse-number n)
source

plusclj

(plus & xs)
source

pos-number?clj

(pos-number? n)
source

positive?clj

(positive? xs)
source

prettyclj

(pretty & args)
source

private-fieldclj

(private-field obj field)
source

private-methodclj

(private-method obj method & args)
source

props->mapclj

(props->map props)

java.util.Properties to map

java.util.Properties to map
sourceraw docstring

ranged-randclj

(ranged-rand start end)
source

rebraceclj

(rebrace this with)

=> (rebrace "{{child}}, I am your {{parent}}" {:child "Luke" :parent "father"})

"Luke, I am your father"

=> (rebrace "{{child}}, I am your {{parent}}"
            {:child "Luke" :parent "father"})

"Luke, I am your father"
sourceraw docstring

remove-deepclj

(remove-deep key-set data)
source

remove-emptyclj

(remove-empty m)

=> (remove-empty {:a nil :b "" :c [] :d 42}) {:d 42}

=> (remove-empty {:a nil :b "" :c [] :d 42})
{:d 42}
sourceraw docstring

remove-empty-keysclj

(remove-empty-keys m)

=> (remove-empty-keys {:a 42 nil 37 "" 28 [] 12 {} 7 :b 34}) {:a 42 :b 34}

=> (remove-empty-keys {:a 42 nil 37 "" 28 [] 12 {} 7 :b 34})
{:a 42 :b 34}
sourceraw docstring

remove-key-nsclj

(remove-key-ns m)
(remove-key-ns m kns)
source

remove-keys-by-prefixclj

(remove-keys-by-prefix m prefix)

removes map entries by a key prefix

=> (def m {:a 42 :foo.bar/zoo 39 :moo 82 :oop.oop/noop :noop})

=> (y/remove-keys-by-prefix m :a) {:foo.bar/zoo 39, :moo 82, :oop.oop/noop :noop}

=> (y/remove-keys-by-prefix m :foo) {:a 42, :moo 82, :oop.oop/noop :noop}

removes map entries by a key prefix

=> (def m {:a 42 :foo.bar/zoo 39 :moo 82 :oop.oop/noop :noop})

=> (y/remove-keys-by-prefix m :a)
   {:foo.bar/zoo 39, :moo 82, :oop.oop/noop :noop}

=> (y/remove-keys-by-prefix m :foo)
   {:a 42, :moo 82, :oop.oop/noop :noop}
sourceraw docstring

replace-in-keysclj

(replace-in-keys m from to)
source

replace-in-kwclj

(replace-in-kw kw from to)

=> (replace-in-kw :foo-bar-baz "bar" "zoo") :foo-zoo-baz

=> (replace-in-kw :foo-bar-baz "bar" "zoo")
:foo-zoo-baz
sourceraw docstring

replace-lineclj

(replace-line path from to)
source

rfmkclj

(rfmk m f)

recursively apply f to each key k of map m

recursively apply f to each key k of map m
sourceraw docstring

rm-sortclj

(rm-sort m)

reverse map sort (by key)

reverse map sort (by key)
sourceraw docstring

seq->in-paramsclj

(seq->in-params xs)
source

show-threadsclj

(show-threads)
from: https://twitter.com/chrishouser/status/1306000820580876288
sourceraw docstring

slurp-resourceclj

(slurp-resource path)
source

squuidclj

(squuid)
tasty sequential UUIDs
from: https://github.com/clojure-cookbook/clojure-cookbook/blob/1b3754a7f4aab51cc9b254ea102870e7ce478aa0/01_primitive-data/1-24_uuids.asciidoc
sourceraw docstring

static-methodclj

(static-method clazz method params)
source

str->bytesclj

(str->bytes xs)
(str->bytes xs enc)
source

str->ednclj

(str->edn xs)
source

str->uuidclj

(str->uuid s)
source

str-valclj

(str-val v)
source

str=clj

(str= s v)

case insensitive

case insensitive
sourceraw docstring

strip-marginclj

(strip-margin string)
(strip-margin string delimiter)
source

suuid?clj

(suuid? s)
source

sval?clj

(sval? v)
source

then-applyclj

(then-apply cf f)
source

then-composeclj

(then-compose cf f)
source

to-alpha-numclj

(to-alpha-num xs)
source

to-doubleclj

(to-double n)
source

to-longclj

(to-long n)
source

trimclj

(trim s)
source

underscore-keysclj

(underscore-keys m)
(underscore-keys from m)
source

upper-caseclj

(upper-case s)
source

uuidclj

(uuid)
source

validateclj

(validate validators fact)
(validate validators fact {:keys [check-all?]})

takes in a sequence of validator functions and a fact to validate returns :valid if all validators pass, otherwise returns a sequence of errors

if check-all? is true, all validators will be run otherwise, validators will be run until the first error is found

example:

(defn purrs? [cat] (or (= (:purrs cat) true) {:error "cat doesn't purr"}))

(defn says-meow? [cat] (or (= (:says cat) "meow") {:error "cat doesn't say meow"}))

(defn one-tail? [cat] (or (= (:tail cat) 1) {:error "cat doesn't have 1 tail"}))

(defn four-legs? [cat] (or (= (:legs cat) 4) {:error "cat doesn't have 4 legs"}))

(validate [purrs? says-meow? one-tail? four-legs?] {:legs 3 :tail 3 :says "bow" :purrs true})

; => [{:error "cat doesn't say meow"} {:error "cat doesn't have 1 tail"} {:error "cat doesn't have 4 legs"}]

(validate [purrs? says-meow? one-tail? four-legs?] {:legs 3 :tail 3 :says "bow" :purrs true} {:check-all? false})

; => [{:error "cat doesn't say meow"}]

takes in a sequence of validator functions and a fact to validate
returns :valid if all validators pass, otherwise returns a sequence of errors

if check-all? is true, all validators will be run
otherwise, validators will be run until the first error is found

example:

(defn purrs? [cat]
  (or (= (:purrs cat) true)
      {:error "cat doesn't purr"}))

(defn says-meow? [cat]
  (or (= (:says cat) "meow")
      {:error "cat doesn't say meow"}))

(defn one-tail? [cat]
  (or (= (:tail cat) 1)
      {:error "cat doesn't have 1 tail"}))

(defn four-legs? [cat]
  (or (= (:legs cat) 4)
      {:error "cat doesn't have 4 legs"}))

(validate [purrs?
           says-meow?
           one-tail?
           four-legs?]
          {:legs 3 :tail 3 :says "bow" :purrs true})

; => [{:error "cat doesn't say meow"}
      {:error "cat doesn't have 1 tail"}
      {:error "cat doesn't have 4 legs"}]

(validate [purrs?
           says-meow?
           one-tail?
           four-legs?]
          {:legs 3 :tail 3 :says "bow" :purrs true}
          {:check-all? false})

; => [{:error "cat doesn't say meow"}]
sourceraw docstring

valueclj

(value v)
source

value?clj

(value? v)
source

zero-uuidclj

source

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

× close