Better HN
topnewbestaskshowjobs
Log inSign up

SomeIdiot

5 karma · joined Apr 1, 2009 (17y ago) · 10 submissions

Submissions

comment 15y ago · link · parent

Nice. http://db.tt/INyKU57

comment 15y ago · link · parent

"ClojureScript does not currently support regular expression literals using #"" "

This one seems like a big deal, given how often I find myself using regexes in clojure. Is it on its way and is there a workaround currently?

comment 15y ago · link · parent

Could you explain what it does?

comment 15y ago · link · parent

1)

    (map #(* % 2) (range 1 10))
2)

    (reduce + (range 1 1000))
3)

    (def string "This is an example tweet talking about scala and sbt.")

    (some #(.contains string %) ["scala", "akka", "play framework", "sbt", "typesafe"])
4)

As a string:

    (slurp "filename")
As a list you could just do:

    (.split (slurp "filename") "\n")
Or if you want a lazy sequence:

    (line-seq (BufferedReader. (InputStreamReader. (FileInputStream. file-path) "UTF-8")))
There are also contrib libraries for this that do it nicer.

5)

    (apply prn (map #(str "Happy birthday" (if (= % 4) " dear NAME" " to you")) (range 1 5)))
6) I'm going to leave this blank for now. It's an easy enough problem, but I can't think of a way of doing it in a nifty one-liner.

Edit: Ahh thought of it now. group-by does it nicely:

    (group-by #(> % 60) [49, 58, 76, 82, 88, 90])
which returns a map with the elements keyed to the result of the anonymous function. In this case:

    {false [49 58], true [76 82 88 90]}
7) Something like

    (xml-seq (clojure.xml/parse the-xml))
probably.

8)

    (apply max [14, 35, -7, 46, 98])

    (apply min [14, 35, -7, 46, 98])
9) Clojure has pmap, which is used just like map is, work is just done in parallel. Also Clojure is known for its concurrency features, which I won't go over here.

10) I'm sure this can be done in a similar amount of code in Clojure, though I am not going to try.

Any comments/corrections are welcome.

comment 15y ago · link · parent

So any interesting ideas for what this can be used for?

comment 17y ago · link · parent

Ah, well that explains it I guess :o)

comment 17y ago · link · parent

Why do you need to check in every 30 minutes?

comment 17y ago · link · parent

Do you know what the name of his/their team name is?

comment 17y ago · link · parent

Frankly the only reason I use it is because I don't know any better player. Not because it is that great. Any tips for good windows players?

comment 17y ago · link · parent

Yeah, apostrophes seem to turn into some wierd jumble (e.g. ’) and so do other charaters. Aside from that, very nice work. Added to my reader.