Utility library for Clojure.
The library targets Clojure 1.8 and above.
when-let*: Multiple binding version of when-let
(use 'kezban.core)
user=> (when-let* [a 1 b 2 c 3]
(println "I'm in love with the coco")
a)
=> "I'm in love with the coco"
=> 1
;;returns nil when one binding is nil or false
user=> (when-let* [a 1 b nil c 3]
(println "Please print me!!!")
a)
=> nil
if-let*: Multiple binding version of if-let
(use 'kezban.core)
user=> (if-let* [a 1 b 2 c (+ a b)]
c)
=> 3
;;returns then part when one binding is nil or false
user=> (if-let* [a 1 b nil c 3]
"Nope not here"
"Here I Am Baby!")
=> "Here I Am Baby!"
->>>: Alternative to -> , ->> and (comp) with one arg
(use 'kezban.core)
;;Applying Left-To-Right
;;First Argument has to be a value(input)!
;; comp equivalent: ((comp #(+ 1 %) #(+ % 1) inc) 5)
;; standard equivalent (+ 1 (+ (inc 5) 1))
user=> (->>> 5 inc #(+ % 1) #(+ 1 %)) ;;5 is the input
=> 8
;; comp equivalent: ((comp inc second reverse) '("a" 2 8 "b"))
;; standard equivalent (inc (second (reverse '("a" 2 8 "b"))))
user=> (->>> '("a" 2 8 "b") reverse second inc) ;;'("a" 2 8 "b") is the input
=> 9
drop-first: derivative function of drop
(use 'kezban.core)
user=> (drop-first [1 2 3])
=> (2 3)
user=> (drop-first [])
=> ()
nth-safe: safe version of nth
(use 'kezban.core)
(def coll [1 2 3 4 5])
user=> (nth-safe coll 0)
=> 1
user=> (nth-safe coll 12)
=> nil
user=> (nth-safe coll 12 "gimme more!")
=> "gimme more!"
third, fourth, fifth, sixth, seventh, eighth, ninth, tenth: addition to first and second
(use 'kezban.core)
(def coll [1 2 3 4 5 6 7 8 9 10])
user=> (third coll)
=> 3
user=> (fourth coll)
=> 4
user=> (fifth coll)
=> 5
user=> (sixth coll)
=> 6
user=> (seventh coll)
=> 7
user=> (eighth coll)
=> 8
user=> (ninth coll)
=> 9
user=> (tenth coll)
=> 10
any?: reverse logic of not-any?
(use 'kezban.core)
(def mixed [1 2 3 4 5 6 7 8])
(def only-odds [1 3 5 7 9])
user=> (any? odd? mixed)
=> true
user=> (any? even? only-odds)
=> false
Copyright © 2016 Ertuğrul Çetin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Can you improve this documentation? These fine people already did:
ertugrulcetin & Ertuğrul ÇetinEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close