Clojure Programming/Examples/API Examples/Sequences
Tools
General
Sister projects
In other projects
user=>(applystr(interpose"|"["hi""mum""and""dad"]))"hi|mum|and|dad"
user=>(interleave[123][:a:b:c])(1:a2:b3:c)
user=>(reverse[123])(321)user=>(applystr(interpose" "(reverse(.split"I am cold"" "))))"cold am I"
user=>(butlast"hello")(\h\e\l\l)
user=>(next[12345])(2345)
user=>(nfirst[[123][456][789]])(23)
user=>(nnext[12345])(345)
user=>(second[:a\b"c"])\b
user=>(nth[12345]3)4
user=>(replace{\l""}"hello world")(\h\e""""\o\space\w\o\r""\d)user=>(applystr(replace{\l""}"hello world"))"heo word"
user=>(conj[123]4)[1234]user=>(conj'(:a:b:c)\d)(\d:a:b:c)
(defnpoly-expandpoly-expand[points](loop[aa(firstpoints)remaining(restpoints)built(emptypoints)](if(empty?remaining)(concatbuilt[aa(firstpoints)])(recur(firstremaining)(restremaining)(concatbuilt[aa(firstremaining)])))))(poly-expand'[abcd])->[abbccdda]
Combine two maps into a more massive map
(merge{:a1}{:b2})=>{:a1,:b2})(merge-with+{:a1}{:a2,:b3})=>{:a3:b3}
user=>(map+[1234][1234])(2468)
user=>(reduce*[234])24; sum the odd numbers to 100;; Not so beautiful code, see next example for a better approach(reduce#(+%1(if(=1(rem%22))%20))(range100)); sum the odd numbers to 100 (Cleaner version)(reduce+(filterodd?(range100)))
user=>(applystr[12]); equivalent to (str 1 2)"12"user=>(let[pair(fn[ab](stra" 'n "b))](applypair["M""Ms"]))"M 'n Ms"user=>(defnfactorial[n](apply*(range2(incn))))#'user/factorialuser=>(factorial5)120