Fork me on GitHub

is there a good beginners guide for regular expression you guys can recommend?


For generic (non-jvm flavoured) regex help I usually end up on - the quickstart page gives a pretty nice overview


awesome thanks!

Josh Horwitz01:03:42

What is the difference between apply and map? They seem very similiar


Map accepts a function and a sequence and runs the function on each item in the sequence. If you have an increment function inc and run (map inc [1 2 3 4 5]) then inc will be called five times (once for each element in the list) and you will have returned a list of the numbers all incremented (i.e numbers 2-6) Apply also accepts a function and a sequence, but instead it will run the function just once with all of the items of the sequence as arguments. (apply + [1 2 3 4 5]) becomes the same as (+ 1 2 3 4 5)

Josh Horwitz02:03:09

ah, ok, thank you! Perfect explanation


is some the best function to use if i want to just want to know if at least 1 element in a sequence matches a predicate?


but... my intuition would be to use (not (not-any? xs)), simply because any? would be the function that i would be looking for simple_smile

Chris O’Donnell16:03:56

that's pretty understandable

Chris O’Donnell16:03:09

we tend to look for solutions resembling ones we're already familiar with simple_smile


yes, i would wish the FP community would just settle on what they call certain operations


Where would be the fun in that… it would make it far too easy to move between languages 😏


(but, yes, it does take a while to get your head around the vast array of functions in clojure.core)


e.g., we have some and some? and we have every? but not every...


(and some and every? take a predicate and a collection whereas some? just takes a value!)


yes, and don't get me started on -> vs ->> !


just pick something and stick with it!


also, some and some? are so different!


And then you have cond-> and some-> 😆


Eventually you just get used to it all (the same as folks eventually get used to Haskell’s Prelude).


yeah, Prelude is suboptimal too