Fork me on GitHub
#beginners
<
2016-03-22
>
adamkowalski00:03:45

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

danmidwood00:03:55

For generic (non-jvm flavoured) regex help I usually end up on http://www.regular-expressions.info/ - the quickstart page gives a pretty nice overview

adamkowalski00:03:57

awesome thanks!

Josh Horwitz01:03:42

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

danmidwood02:03:08

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

lmergen16:03:19

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?

lmergen16:03:01

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

lmergen16:03:38

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

seancorfield16:03:01

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

seancorfield16:03:26

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

seancorfield16:03:16

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

seancorfield16:03:37

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

lmergen16:03:07

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

lmergen16:03:13

just pick something and stick with it!

lmergen16:03:59

also, some and some? are so different!

seancorfield16:03:01

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

seancorfield16:03:02

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

lmergen16:03:22

yeah, Prelude is suboptimal too