#clojure log - Oct 22 2010

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:14 _rata_: well... I've finally bound the keyseq C-S-right to what M-x right does and the same for left... much better than M-x right

0:15 at least it allows me to change many buffers in one row

0:17 (does "in one row" mean "at the same time" or something similar in english?)

0:26 amalloy: _rata_: "in a row"

0:29 _rata_: amalloy: thanks :)

0:30 LauJensen: Good morning

0:31 _rata_: good morning LauJensen

0:32 amalloy: morning LauJensen

0:35 _rata_: I need something like atoms or refs but immutable... I've been thinking of this problem a lot a yet can't figure out a solution

0:37 maybe something lazy is the solution

0:37 I haven't think of that yet

0:37 LauJensen: eh?

0:37 You need something like a mutable construct, yet immutable?

0:37 _rata_: s/think/thought/

0:37 sexpbot: <_rata_> I haven't thought of that yet

0:38 _rata_: I need refs just to have mutually-referring things, not for the mutable part

0:38 amalloy: heh, sounds like the named anonymous functions we were discussing a few hours ago

0:38 LauJensen: hehe

0:38 _rata_: What are you working on ?

0:39 _rata_: a continuous-time Markov chain (CTCM) simulator

0:40 but for a special language called kappa

0:40 LauJensen: Ok. Since refs/atoms only exist to allow mutability, Im guessing you mean you want immutable because you want to drive progress by function application ?

0:41 _rata_: indeed the project is named clj-kappa... I wasn't really very original on the name :P

0:41 LauJensen: why not kapjure? :)

0:41 kapjure the flag?

0:42 _rata_: hahahaaha that's a nice name :)

0:42 thank you very much for the idea

0:42 I'll propose it

0:43 LauJensen: np :)

0:44 _rata_: I want immutable just because I prefer it

0:44 I'd like to have a function gen-event that creates a new states based on the rules and the prior state... I wouldn't like it to mutate the prior state

0:45 amalloy: and mutable because it's easier :)

0:46 _rata_: hahahaha... no, I don't want mutable... I just wanted refs for referring to kappa agents from other kappa agents

0:46 maybe lazyness can help me there

0:47 LauJensen: _rata_: it says like you need a sequence [state0 state1 state2] etc

0:47 _rata_: just a random intuition... probably I'm wrong

0:48 LauJensen, yes, I'd love to be able to generate such a sequence

0:48 perhaps that's too much in memory though

0:49 LauJensen: Well you're in luck. Clojures standard vector will do just fine. Build it with map, conj, for, or whatever makes sense for your application

0:49 _rata_: hahahahaha... the problem is generating the states and defining the state

0:49 amalloy: i think rata's dream is to have, within a state, objects that refer to each other

0:50 _rata_: yeah, that's it

0:50 amalloy: it's a dream i can sympathize with

0:50 _rata_: :)

0:52 I've thought of having an id for each kappa agent and then, instead of having seqs as collections of kappa agents, to have maps id -> kappa agent

0:53 amalloy: _rata_: that's really the only way you can do it immutably

0:53 _rata_: lazy isn't useful for this?

0:53 s/lazy/lazyness/

0:53 sexpbot: <_rata_> lazyness isn't useful for this?

0:54 amalloy: i don't see how it will help, but i'd love to be enlightened

0:55 _rata_: maybe a trip to #haskell land will enlighten me too :)

0:56 LauJensen: _rata_: Im quite convinced you'll come back with monads

0:56 _rata_: hahahaahaha :)

0:56 I don't understand them yet... so the trip would become a long one

0:56 amalloy: yes, monads are like a disease, except also magic

0:57 ,domonad

0:57 clojurebot: java.lang.Exception: Unable to resolve symbol: domonad in this context

0:57 amalloy: ,clojure.contrib.monad/domonad ;?

0:57 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.monad

0:57 LauJensen: _rata_: monads are what you do when you dont have reference types

0:57 (+ a little extra)

0:57 KirinDave: Figured out the ab thing I was experiencing

0:58 ab consideres a request a failure if content-length changes over the duration of the test

0:58 _rata_: LauJensen, that's interesting... maybe they could be useful and I'm not even taking them into account

0:59 amalloy: _rata_: one classic use of monads is the ability to simulate mutability in a functional way

0:59 _rata_: do you have a good reference for learning about monads?

0:59 amalloy: $google clojure monad tutorial amalloy

0:59 sexpbot: First out of 3 results is: #clojure log - Oct 07 2010

0:59 http://clojure-log.n01se.net/date/2010-10-07.html

1:00 amalloy: boo, it's not in there

1:01 _rata_: try http://intensivesystems.net/tutorials/monads_101.html

1:01 i found it enlightening and challenging

1:05 ymasory: sorry of this is a dumb question, but what separates clojure's typing from python-style duck-typing? is there a difference?

1:08 amalloy: ymasory: it's basically the same. i don't know about the internals of python, but clojure will call methods on any object so long as those methods exist. what it won't do is implicitly convert to "equivalent" types in order to make an operation work

1:08 ,(+ "1" 5)

1:08 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number

1:08 amalloy: ,(.length 5)

1:08 clojurebot: java.lang.IllegalArgumentException: No matching field found: length for class java.lang.Integer

1:09 amalloy: ,(.size [1 12])

1:09 clojurebot: 2

1:09 ymasory: amalloy: thanks

1:09 amalloy: ,(.size "1 2 3")

1:09 clojurebot: java.lang.IllegalArgumentException: No matching field found: size for class java.lang.String

1:09 amalloy: ,(.size (seq "1 2 3"))

1:09 clojurebot: 5

1:09 ymasory: i'm so used to the term "duck typing" only being used in reference to python and ruby i was wondering why

1:09 amalloy: it's used in clojure a little

1:10 ymasory: why just a little?

1:10 amalloy: because java is strongly typed, and clojure relies on the java type system, it has to be strongly typed at some level

1:11 ymasory: right

1:12 thanks again

1:23 kumarshantanu: ,(binding [*assert* false] (assert false))

1:23 clojurebot: java.lang.AssertionError: Assert failed: false

1:24 kumarshantanu: am I missing something in the assert? I thought it is supposed to return nil

1:25 amalloy: ,*assert*

1:25 clojurebot: true

1:25 amalloy: ,(binding [*assert* false] *assert*)

1:25 clojurebot: false

1:26 amalloy: ,(doc assert)

1:26 clojurebot: "([x]); Evaluates expr and throws an exception if it does not evaluate to logical true."

1:28 tonyl: ,(source assert)

1:28 clojurebot: java.lang.Exception: Unable to resolve symbol: source in this context

1:28 amalloy: ~source assert

1:28 tonyl: cool source

1:29 ,(binding [*assert* false] (assert false))

1:29 clojurebot: java.lang.AssertionError: Assert failed: false

1:29 tonyl: should've return nil then

1:29 amalloy: ,(let [*assert* false] (assert false))

1:29 clojurebot: java.lang.AssertionError: Assert failed: false

1:29 amalloy: hm

1:29 kumarshantanu: this http://clojure.org/special_forms#toc10 seems to say that *assert* can control whether the assertion actually takes place

1:30 tonyl: which means if *assert* is false it won't take place

1:31 shouldn't throw an exception, as the doc says

1:31 amalloy: ,(var *assert*)

1:31 clojurebot: #'clojure.core/*assert*

1:31 amalloy: ,(meta (var *assert*))

1:31 clojurebot: {:ns #<Namespace clojure.core>, :name *assert*}

1:31 kumarshantanu: ,(binding [*assert* false] (with-bindings (assert false)))

1:31 clojurebot: java.lang.AssertionError: Assert failed: false

1:32 tonyl: that's peculiar

1:32 kumarshantanu: bug?

1:32 tonyl: ~source when

1:33 amalloy: kumarshantanu: seems unlikely. it's a pretty un-subtle feature; if there were a bug i doubt we'd be the first to notice

1:34 kumarshantanu: I am behind a proxy that won't let me see the source (the tinyurl one), but never mind

1:34 tonyl: just type (source assert) in your clj repl

1:35 kumarshantanu: tonyl: yup

1:37 tonyl: ,(binding [*assert* false] (when *assert* "im here"))

1:37 clojurebot: nil

1:37 amalloy: i think the issue is that assert, being a macro, has no access to the current value of vars

1:38 tonyl: yeah, it seams it is a macro evaluation problem

1:38 *seems

1:40 a macro is just a fn isn't it?

1:41 amalloy: macros are functions with two special properties

1:41 their arguments are not evaluated - they take the forms passed in as literals

1:41 their return value is expanded in place as code

1:42 i suspect the issue is that *assert* is special

1:42 if you rewrite the assert macro so that it looks at a different var, it behaves fine

1:42 tonyl: so the (when *assert* part of the assert macro should still be accessed

1:43 kumarshantanu: ,(binding [*assert* false] (if *assert* (assert false))) ; +yay!+

1:43 clojurebot: nil

1:44 tonyl: that is as much as I know of macros

1:44 maybe somebody in the group would know more about it. If it is a bug of not

1:45 *or not

1:46 well i am leaving, laters. and anybody at conj have fun and take video of the talks :P please

1:48 amalloy: quel bafflement

1:48 but i'm gonna follow tony's lead. night folks

1:48 kumarshantanu: I posted the question on the list

1:49 amalloy: thanks

4:44 esj: Yello

4:47 angerman: h

4:47 i

6:27 bOR_: small question on namespaces and emacs development. If I C-c C-r my (ns burrows.core ... ... ) function, I cannot just do another C-c C-r with (in-ns 'burrows.core), but have to copy-paste that to the slime-repl. I am probably just not understanding something

6:28 anyone knows what? :-)

6:28 e.g. (in-ns 'burrows.core) doesn't switch the namespace in the repl window.

6:29 raek: akhudek: glad to help! i cloned your fork and from what I can tell, it works perfectly.

6:29 akhudek: (seq "flüggåɘnkð€čhiœßølʃênn") returns a sequence of the consistituent characters correctly (an easy test for encoding issues)

6:30 bOR_: yes, slime keeps a file-namespace mapping

6:30 bOR_: try C-c M-p

6:31 it changes the repl namespace to the on of the current file

6:31 bOR_: thanks!

6:31 raek: (it is listed at http://github.com/technomancy/swank-clojure, among other very useful commands)

6:34 bOR_: raek do you know what the function is that is tied to C-c M-p? Want to try if I can just call that function when I block-select a large part of my file with C-c C-r

6:35 raek: well, you can find out with C-h k

6:37 bOR_: for me C-h k C-c M-p gave "C-c M-p runs the command slime-repl-set-package"

6:37 bOR_: thanks for the education. made a note :-)

6:37 raek: Emacs is a big world

6:37 I don't judge you... :)

7:04 G0SUB: Conj goers, are you ready?

7:06 esj: *sniff*

7:24 Uppercut: , (seq "1 2 3")

7:24 clojurebot: (\1 \space \2 \space \3)

7:24 Uppercut: (seq (1 2 3))

7:24 , (seq (1 2 3))

7:24 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

7:24 Uppercut: ok

7:25 bartj: Uppercut, ?

7:28 Uppercut: just a test to know if it prints "4"

8:02 drewr: what's for breakfast?

8:04 esj: the ill conceived preconcepiton of mutabilitly !

8:04 *BAM**

8:04 and then the ravenous hord of Clojurians

8:05 will turn on any other silly traditions that dare show their face

8:05 and in my case - more coffee, as I'm clearly lacking...

8:12 Uppercut: , (fn [& vals] (map #(apply % vals) 20)

8:12 clojurebot: EOF while reading

8:12 Uppercut: , (fn [& vals] (map #(apply % vals) 20))

8:12 clojurebot: #<sandbox$eval5082$fn__5083 sandbox$eval5082$fn__5083@5805bc>

8:13 Bahman: Hi all!

8:14 esj: wotcha

8:26 Uppercut: , (1 to 50) map(r =>r*r) toSet

8:26 clojurebot: java.lang.Exception: Unable to resolve symbol: to in this context

8:26 Uppercut: , (1 to 50).map(r =>r*r).toSet

8:26 clojurebot: java.lang.Exception: Unable to resolve symbol: to in this context

8:26 Uppercut: , (1 to 50).map(r =>r*r)

8:26 clojurebot: java.lang.Exception: Unable to resolve symbol: to in this context

8:26 Uppercut: :/

8:26 raek: hrm, what language is that?

8:27 (map (fn [r] (* r r)) (range 1 51))

8:27 ,(map (fn [r] (* r r)) (range 1 51))

8:27 clojurebot: (1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 729 784 841 900 961 1024 1089 1156 1225 1296 1369 1444 1521 1600 1681 1764 1849 1936 2025 2116 2209 2304 2401 2500)

8:27 raek: ,(for [i (range 1 51)] (* i i))

8:27 clojurebot: (1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 729 784 841 900 961 1024 1089 1156 1225 1296 1369 1444 1521 1600 1681 1764 1849 1936 2025 2116 2209 2304 2401 2500)

8:27 Uppercut: you´re right, was Scala. I need clojure too

8:28 raek: scala seems to be a neat language

8:29 also, toSet is (set the-collection) in Clojure

8:30 Uppercut: hmm

9:02 vijaykiran: ,(time (apply + (distinct (concat (range 0 1000 5) (range 0 1000 3)))))

9:02 clojurebot: 233168

9:02 "Elapsed time: 34.862 msecs"

9:03 vijaykiran: ,(time (reduce + (distinct (concat (range 0 1000 5) (range 0 1000 3)))))

9:03 clojurebot: 233168

9:03 "Elapsed time: 11.951 msecs"

9:07 raek: vijaykiran: variadic + uses reduce internally

9:08 iirc, it is considered good style to use reduce for these cases (with exceptions for apply str and apply concat)

9:09 vijaykiran: raek: (clojure noob here) just started learning was wondering which one is better/faster

9:09 tmarble: hey, is there a separate channel for clojure-conj?

9:10 raek: ok. they are the same in this case, since + with more than two arguments is implemented with reduce +

9:11 tonyl: morning

9:11 vijaykiran: raek: thanks!

9:12 bforester: g'morning.

9:12 raek: but if reduce makes sense for your function, use that variant instead

9:12 (unless that function is str or concat)

9:12 since reduce can be more performant

9:21 sempah: How can I iterate over a list -> passing each element + a second fix parameter to a given function and put each result of the function in a map?

9:22 G0SUB: woohoo! At the Conj!

9:23 AWizzArd: Greetings :)

9:23 joly: Hello!

9:24 sempah: my list: (def l '("a", "b", "c")) + my function: (defn f [s1 s2] (str s1 s2))

9:24 tonyl: sempah: (map #(into {} (myfn % fix-param)) mylist)

9:24 sempah: now I want a map/list with a+my second parameter passed

9:25 raek: sempah: my guess would be a (into {} (for [x coll] [...key... ...val...]))

9:25 but I might have misinterpreted the last requirement

9:25 sempah: ok, lets say the fix parameter would be "d"

9:26 the final map/list should be: "ad", "bd", "cd"

9:26 the first letter comes from the list

9:26 raek: #(f % "d") gives a function that you can use in map

9:26 sempah: the second from the fix parameter

9:27 tonyl: ,(map #(str % "d") '("a" "b" "c"))

9:27 clojurebot: ("ad" "bd" "cd")

9:27 raek: ,(map #(f % "d") ["a" "b" "c"])

9:27 clojurebot: java.lang.Exception: Unable to resolve symbol: f in this context

9:27 raek: right.

9:27 also, map + anonymous functions can also be expressed with 'for'

9:28 ,(for [x ["a" "b" "c"]] (str x "d"))

9:28 clojurebot: ("ad" "bd" "cd")

9:28 tonyl: oh yeah, destructing

9:28 sempah: first thx for the answers, have to evaluate em

9:29 mike5160: raek: i got emacs and everything up and running (on my 3rd attempt). just wanted to thank you for your input yesterday.

9:29 raek: np :-)

9:35 sempah: thx raek and tonyl

9:35 it's really annoying coming from an imperative language -.-

9:36 tonyl: been there (still there for some times :P)

9:38 Drakeson: How does one refer to a sibling namespace (foo.bar.baz.x -> foo.bar.baz.y), without spelling out the common part (foo.bar.baz) ?

9:41 raek: Drakeson: in one way or another, you have to...

9:41 there is no special connection between namespaces that share prefixes

9:43 (assuming you asked about how to do this inside one of the sibling namespaces)

9:43 (ns foo.bar.baz.x (:require foo.bar.baz.y)) ; unavoidable

9:44 (ns some.other.ns (:require (foo.bar.baz x y))) ; shortcut

9:58 G0SUB: fogus finished his talk. it was great.

9:59 esj: G0SUB: are there any video cameras in the room ?

10:00 xkb: yup, there's 2 herre

10:00 esj: xkb: that's awesome news, can't wait to see the talks

10:05 tonyl: ooh god, i wish i was there

10:06 sempah: I know immutabilty first, but how can I add a value to an existing list in a loop?

10:06 have something like doseq ... list.add(value)

10:06 Chousuke: is it a mutable list? :P

10:07 if it isn't, then you need to restart the loop with a new list with the value added :)

10:07 sempah: the default list is immutable or?

10:07 Chousuke: yes

10:08 ie. (loop [l ()] ... (recur (conj l 1))

10:08 your loop must be like a recursive function. You can't modify things, but you can "restart" the loop with new values

10:09 esj: sempah: but the general idiom is to return a NEW list, which is formed by cons'ing a value to an existing list, ala

10:09 ,(cons 1 (2 3 4))

10:09 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

10:09 esj: ,(cons 1 '(2 3 4))

10:09 clojurebot: (1 2 3 4)

10:09 esj: bah

10:09 tmarble: well

10:10 Chousuke: If you're translating an imperative loop that usually means you'll have to spend some time thinking about how to express it recursively

10:10 sempah: but I have a list that I want to print at the end of the loop

10:10 Chousuke: sempah: then have the loop return the list, and print the return value of the loop

10:10 G0SUB: esj: yes. the videos will be uploaded.

10:11 esj: G0SUB: back in Her Majesty's Green and Pleasant Land, I am doing a little dance of joy :)

10:11 G0SUB: esj: haha!

10:11 esj: G0SUB: a video of which will _not_ be uploaded :P

10:11 Chousuke: something like (print (loop [l ()] (if (done-with? l) l (recur (do-stuff-with l)))) :P

10:11 G0SUB: esj: lol

10:12 Chousuke: where do-stuff-with returns a new list

10:12 and done-with? determines if the loop needs to terminate

10:13 of course I wouldn't recommend putting loop statements as function arguments

10:14 tonyl: ,(print (loop [l '()] (if (= 5 (count l))) l (recur (cons :t l)))))

10:14 clojurebot: java.lang.Exception: Too few arguments to if

10:14 Chousuke: If you don't need the value of the list, you can just do (print l) instead of returning l. But even better might be making a function out of the loop

10:14 sempah: looks a lil bit chinese to me :/

10:15 Chousuke: Good, idiomatic Clojure code contains relatively few explicit loops

10:15 using higher-order functions and recursive functions is more common.

10:15 raek: oh, the Conj... how I wish I was there!

10:16 unfortunately, the spacial-temporal-monetary interval was of too high magnitude

10:17 esj: sempah: Don't worry, take it slow and easy, and you'll get there. Its a real mind job at first.

10:17 raek: :)

10:17 tonyl: ,(loop [l '()] (if (= (count l) 5) (println l) (recur (cons :ty l))))

10:17 clojurebot: (:ty :ty :ty :ty :ty)

10:19 tonyl: ,(loop [l '(), val 0] (if (= (count l) 5) (println l) (recur (cons val l) (inc val))))

10:19 clojurebot: (4 3 2 1 0)

10:20 tonyl: is there a fn like cons that appends it to the end instead to the beginning?

10:20 raek: sempah: in my experience, it is far more common to compose functions in clojure's library than writing loops

10:20 sempah: didnt finish to understand your first loop, u'll posting your 2nd :)

10:20 raek: tonyl: lists can't do that, but vectors can

10:20 tonyl: aah true

10:21 Chousuke: there's concat though

10:21 raek: with conj

10:21 Chousuke: but don't overuse it

10:21 doing lots of concats adds up overhead

10:21 and eventually your stack will be blown :P

10:22 tonyl: why? it holds the head?

10:22 Chousuke: well a concat creates a new lazy seq that holds a reference to both of the seqs that are concatenated

10:23 so if you concat something that's a result of a concatenation, you have one more level of indirection before you can get to the actual items.

10:23 raek: I think the result will be something like (concat () (concat (1) (concat (2) ((concat (3) (...)))))

10:23 modulo one of the parens

10:23 hiredman: danlarkin: !!

10:24 tonyl: ooh got it

10:24 ,(loop [l [], val 0] (if (= (count l) 5) (println l) (recur (conj l val) (inc val))))

10:24 clojurebot: [0 1 2 3 4]

10:25 raek: conj works for lists too. (conj l e) ~= (cons e l)

10:26 tonyl: yeah, but they are in descending order

10:26 ,(into '() (for [x (range 4 -1 -1)] x))

10:26 clojurebot: (0 1 2 3 4)

10:26 tonyl: a bit simpler :P

10:27 raek: ,(into () (range 4 -1 -1)) ; even simpler :P

10:27 clojurebot: (0 1 2 3 4)

10:27 raek: ,(range 4 -1 -1) ; nevermind...

10:27 clojurebot: (4 3 2 1 0)

10:28 tonyl: oh snap, yeah raek

10:28 i overthink it

10:28 raek: hrm, interesting way of implementing reverse

10:28 tonyl: for numbers

10:28 hiredman: even my mifi is lagged

10:29 raek: (defn reverse [coll] (into () coll))

10:29 pbuckley: hiredman: you at the conj? laggy network?

10:29 tonyl: is reduce faster than into?

10:29 hiredman: yes yes

10:30 pbuckley: same here

10:30 tonyl: or "better" in any sense?

10:31 esj: tonyl: reduce is more general, hence into is better form if it does the job

10:31 sempah: http://paste.bradleygill.com/index.php?paste_id=58064 this is my function

10:31 tonyl: esj: thanks

10:31 sempah: i'll pass in n = times, f = function, words = string, l = liste

10:32 it works, but I want to know the average time of the run

10:32 raek: tonyl: (defn into [to from] (reduce conj to from))

10:32 tonyl: instead of testing speed within the function you could just make the function and call it like (time (testit ...))

10:33 sempah: with a list, adding each runtime

10:33 tonyl: raek: haha i see, i was fooled by into

10:33 sempah: yea I know the time macro

10:33 but how I will get the average time

10:33 with the time macro

10:33 tonyl: that's true

10:34 sempah: and I do not want "estimated time ..."

10:34 danlarkin: hiredman: internetsssssssssss!!!!!!!!!

10:34 sempah: so I thought a list, adding each time would do it

10:35 hiredman: danlarkin: do you have soome?

10:35 raek: when doing quick tests, I have seen people using (time (dotimes [_ 1e6] ...)) to compare solutions

10:35 danlarkin: hiredman: I have plenty to share

10:36 sempah: what does 1e6 mean?

10:36 esj: 1million

10:36 tonyl: engineering notation

10:36 raek: ,1e6

10:36 clojurebot: 1000000.0

10:36 tonyl: 1 with 6 ceros

10:36 sempah: yea I know what a million is ;)

10:37 tonyl: :P raek bit me to it

10:38 i haven't use dotimes but it seems more idomatic then system/nanotime average, but i don't know if dotimes affects the execution time

10:38 esj: sorry, i thought you'd asked, my bad.

10:38 sempah: hm

10:39 tonyl: cool

10:39 how is Conk?

10:39 *Conj?

10:39 sempah: looked some other jvm languages before, in scala/groovy there is something like: list.each { element => print(element.join(, ) }

10:40 is there something similar in clojure?

10:40 ,(print '(1 2 3))

10:41 clojurebot: (1 2 3)

10:41 esj: ,(map prn (interpose "," "The quick brown fox"))

10:41 clojurebot: (nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil)

10:41 tonyl: just want to print each element in a list?

10:41 sempah: yes

10:41 maybe format it

10:41 ./join it with a ,

10:42 esj: well, printing aside my example will do that

10:43 something like

10:43 ,(apply str (interpose "," [1 2 3 4 5]))

10:43 clojurebot: "1,2,3,4,5"

10:43 sempah: ;>

10:43 esj: if i understand ?

10:44 sempah: yes

10:44 this it what I wanted

10:44 esj: cool

10:49 tonyl: ,(map prn (interpose "," "the quick brown fox"))

10:49 clojurebot: (nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil)

10:49 tonyl: ,(map prn (interpose \, "the quick brown fox"))

10:49 clojurebot: (nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil)

10:49 tonyl: ,(interpose \, "the quick brown fox")

10:49 clojurebot: (\t \, \h \, \e \, \space \, \q \, \u \, \i \, \c \, \k \, \space \, \b \, \r \, \o \, \w \, \n \, \space \, \f \, \o \, \x)

10:50 tonyl: ,(apply str (interpose \, "the quick brown fox"))

10:50 clojurebot: "t,h,e, ,q,u,i,c,k, ,b,r,o,w,n, ,f,o,x"

10:50 tonyl: ,(apply #(str % "#") (interpose \, "the quick brown fox"))

10:50 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (21) passed to: sandbox$eval5204$fn

10:55 sempah: gtg

10:55 thx for all your help :)

11:00 G0SUB: Luke van der Hart talking about Clojure Zippers.

11:07 esj: G0SUB: keep turning that knife buddy ! :P

11:09 G0SUB: I'm just kidding :)

11:22 edoloughlin: Nice chat implementation with history and linking of responses to oroginal posts at stackoverflow.com. Clojure room is at http://chat.stackoverflow.com/rooms/68/clojure

11:28 Drakeson: how do call a function and get a vector of it's printed output and its returned value?

11:29 qbg: The latest master causes the following error for me: http://gist.github.com/640760

11:30 tonyl: Drakeson: what kind of value does the function print and returns?

11:30 Drakeson: sounds like a work for the vec function

11:32 qbg ^double should be ^Double

11:33 qbg: I don't have the latest master so I can't check it right now

11:33 qbg: If you remove the ArrayList type hint, it works

11:35 Drakeson: tonyl: nevermind, thanks

11:35 qbg: So currently primitive fns can only return an Object

11:38 tonyl: Drakeson: np

11:38 qbg: isn't ArrayList an object

11:39 qbg: Yes it is, but the return type of the function isn't Object

11:39 tonyl: oh interesting, that defeats the point of type hinting fn's

11:40 qbg: Well, the interfaces that primitive fns use can only return double, long, and Object

11:40 Which makes me wonder how that fn can be defined at all...

11:41 tonyl: it seems that the only Object implementation is not supported to the interface level, but the fn level.

11:41 qbg: This problem didn't exist with the older primitive fn system

11:42 tonyl: no, i have 1.2.0 and it works fine with the code you posted

11:42 qbg: 1.2 didn't have primitive fns

11:42 tonyl: maybe that is why :P

11:43 qbg: Before in 1.3 you had to use ^:static, and in that system it worked

11:44 Now static is the default

11:45 tonyl: ok, that is better, then doto returns an Object

11:46 that can break some code

11:46 hiredman: qbg: not exactly

11:46 qbg: explain

11:46 hiredman: non-dynamic vars are not the same thing as static

11:48 with static var resolution is only done at compile time, but with the new default non-dynamic vars var resolution is done at run time but cached

11:49 qbg: With ^:static the fn had a known class so it could use a static method on it, hence the need for interfaces in the new system, right?

11:50 hiredman: qbg: that doesn't scan

11:52 qbg: The class of the fn was known with ^:static so the code could use a static call on it; since the exact class can't be known now (since ^:static is currently a nop), interfaces must be use for primitive support, and hence the limited options

11:52 Right?

11:52 hiredman: I don't know anything about primitive support, just var resolution

11:56 bforester: should I do this bit of code any differently?

11:56 qbg: Well, 358 (IIRC) interfaces were added to IFn

11:56 bforester: ,(map #(reduce (fn [key value] (assoc (hash-map) key value)) (.split %1 "=")) (.split "A=3,B=4,C=234234" ","))

11:56 clojurebot: ({"A" "3"} {"B" "4"} {"C" "234234"})

11:59 raek: (assoc (hash-map) key value) -> (hash-map key value)

11:59 (fn [key value] (assoc (hash-map) key value)) -> #(hash-map %1 %2)

11:59 qbg: ,(map hash-map (partition 2 (.split "A=3,B=4,C=234234" "=|,")))

11:59 clojurebot: java.lang.IllegalArgumentException: No value supplied for key: clojure.lang.LazySeq@bd3

11:59 bforester: can't nest the anon functions.

12:00 raek: ,(for [x (.split "A=3,B=4,C=234234" ",")

12:00 clojurebot: EOF while reading

12:00 bforester: with the # macro

12:00 raek: eh

12:00 anyway, map + anon fn -> for

12:01 bforester: ah

12:01 I'll get that working: map + anon fn -> for

12:02 qbg: ,(map #(apply hash-map %) (partition 2 (.split "A=3,B=4,C=234234" "=|,")))

12:02 clojurebot: ({"A" "3"} {"B" "4"} {"C" "234234"})

12:04 raek: ,(into {} (for [pair (.split "A=3,B=4,C=234234" ",")] (vec (.split pair "="))))

12:04 clojurebot: {"A" "3", "B" "4", "C" "234234"}

12:05 raek: or maybe this as a pre processing:

12:05 Uppercut: , (+ (map (fn [r] (* r r)) (range 1 51)))

12:05 clojurebot: java.lang.ClassCastException

12:06 Uppercut: , (+ (map (range 1 9)))

12:06 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$map

12:06 raek: hrm, neverminf

12:06 qbg: ,(apply + (map (fn [r] (* r r)) (range 1 51)))

12:06 clojurebot: 42925

12:06 Uppercut: :)

12:07 raek: ,(reduce + (for [r (range 1 51)] (* r r)))

12:07 clojurebot: 42925

12:07 Uppercut: with reduce cannott i use map?

12:07 bforester: thanks raek, qbg

12:08 qbg: Uppercut: explain

12:08 Uppercut: ,(apply (reduce + (map (fn [r] (* r r)) (range 1 51))))

12:08 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$apply

12:08 qbg: ,(reduce + (map (fn [r] (* r r)) (range 1 51)))

12:08 clojurebot: 42925

12:08 Uppercut: hmm

12:08 qbg: apply needs a fn to apply

12:09 Uppercut: , (.contains (map (fn [r] (* r r)) (range 1 51))) 25)

12:09 clojurebot: java.lang.IllegalArgumentException: No matching field found: contains for class clojure.lang.LazySeq

12:09 raek: ,(let [x [1 2 3 4]] (apply + x))

12:09 clojurebot: 10

12:09 Uppercut: and to check if a map contains a number

12:09 qbg: ,(some #{25} (map (fn [r] (* r r)) (range 1 51))))

12:09 clojurebot: 25

12:09 raek: that is not map - the data structure

12:09 qbg: ,(some #{26} (map (fn [r] (* r r)) (range 1 51))))

12:09 clojurebot: nil

12:11 Uppercut: does I need to iterate a data structure to check, one by one?

12:11 qbg: Yes, since it is a lazy seq

12:11 Uppercut: , (map (fn [r] (* r r)) (range 1 11)))

12:11 clojurebot: (1 4 9 16 25 36 49 64 81 100)

12:12 Uppercut: , (dotimes [n(n+1)] "test" )

12:12 clojurebot: java.lang.Exception: Unable to resolve symbol: n+1 in this context

12:14 tonyl: ,(let [n 4] (dotime [n (inc n)] "test"))

12:14 clojurebot: java.lang.Exception: Unable to resolve symbol: dotime in this context

12:14 tonyl: ,(let [n 4] (dotimes [n (inc n)] "test"))

12:14 clojurebot: nil

12:14 * Sweetshark is wondering if there is any possibility of enclojure being additionally licensed as GPL as. No flames intended, but I just started with clojure and found at least two projects running into problems with that. enclojure for example has EPL1 and GPL2 license headers side by side in its current git repo - sounds like a layers nightmare to me ...

12:15 tonyl: ,(let [n 4] (dotimes [n (inc n)] (prn "test ")))

12:15 clojurebot: "test " "test " "test " "test " "test "

12:17 Sweetshark: meh, I meant clojure of cause. enclojure is likely just following suit as did others (swank-clojure f.e. says somehing about being GPL too)

12:18 Uppercut: , ,(let [n 40] (dotimes [n (inc n)] (if ( = 25 (map (fn [r] (* r r)) (range n (+ n 1)))) )true ))

12:18 clojurebot: java.lang.Exception: Too few arguments to if

12:18 raek: Sweetshark: which Clojure file are under GPL?

12:18 Uppercut: help

12:19 qbg: Uppercut: What are you trying to do?

12:20 Uppercut: check if a number 25 exists in that list or Data structure de (1 4 9 16 25....)

12:20 qbg: ,(boolean (some #{25} (map (fn [r] (* r r)) (range 1 51)))))

12:20 clojurebot: true

12:20 qbg: ,(boolean (some #{26} (map (fn [r] (* r r)) (range 1 51)))))

12:20 clojurebot: false

12:21 qbg: (you wouldn't need the boolean cast to use it in a conditional)

12:21 Uppercut: yeah

12:21 qbg: ,(doc some)

12:21 clojurebot: "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"

12:21 Sweetshark: raek: clojure is only EPL AFAIK, but at least enclojure has both GPL2/EPL1 headers in the source, swank-clojure seems to have been GPL2 once, but has moved to EPL1.

12:23 tonyl: ,(map * (range 1 51)

12:23 clojurebot: EOF while reading

12:23 tonyl: ,(map * (range 1 51))

12:23 clojurebot: (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50)

12:29 raek: Sweetshark: from what I can tell from the license texts and from what I have heard from others, EPL'ed code and GPL'ed code can't be combined. (LGPL should be ok though)

12:30 basically, if code C = A + B, where A is GPL'ed and B is EPL'ed, the GPL requires C, and thus B, to be GPL'ed too

12:34 I don't think Rich has any plans for releasing Clojure under the GPL. this has been discussed many times before, so if you browse the mail archive or the IRC logs, you could probably find the rationale for all this

12:34 Sweetshark: raek: well, EPL allows relicensing (so in theory you could relicense to another license), but it has some restriction on how the stuff is allowed to be relicensed which is incompatible with the GPL. so enclojure is violating both the EPL and the GPL ...

12:35 raek: heh

12:37 ohpauleez: I thought you could now relicense to GPL3 from EPL? Maybe I'm thinking of Apache2 and GPL3 compatibility

12:37 Uppercut: , (sort-by val > (frequencies “abcdaabccc”))

12:37 clojurebot: java.lang.Exception: Unable to resolve symbol: “abcdaabccc” in this context

12:37 raek: compability with Apache2 was one of the goals of GPLv3, at least...

12:38 ohpauleez: ahh ok, thanks raek

12:38 Uppercut: , (sort-by second (frequencies “abcdaabccc”))

12:38 clojurebot: java.lang.Exception: Unable to resolve symbol: “abcdaabccc” in this context

12:38 tonyl: , (sort-by val > (frequencies (seq “abcdaabccc”)))

12:38 clojurebot: java.lang.Exception: Unable to resolve symbol: �abcdaabccc� in this context

12:38 raek: but I dunno about any GPLv3 and EPL specifics

12:38 tonyl: , (sort-by val > (frequencies (seq "abcdaabccc")))

12:38 clojurebot: ([\c 4] [\a 3] [\b 2] [\d 1])

12:38 tonyl: wrong quotes

12:39 Uppercut: ah

12:39 ohpauleez: Who's at the conj today?

12:40 Sweetshark: ohpauleez: would not matter as the files in question are EPL1 and GPL2+classpath (no "or later")

12:41 raek: I'm not a lawyer, so take all this with a metric assload of salt

12:41 ohpauleez: Sweetshark: ahh ok

12:42 Uppercut: what is the conj?

12:42 raek: the first clojure conference

12:42 i really wished I was there...

12:43 http://first.clojure-conj.org/

12:45 Sweetshark: oh, btw are there any other GUI-repls implementations available that are easily pluggable into an existing application. (I am thinking of adding a clojure repl to OpenOffice.org which is LGPL3+SCA to make the licensing insanity even more fun, so I am looking for something that is at least consistent with itself licensewise ...)

12:46 ohpauleez: raek: You and me both, had to cancel because of work

12:48 Sweetshark: (the OOo API isnt ttoo much fun in java because of all the static typing going on and it isnt too much fun in Basic because of ... Basic, but with clojure it could be really nifty ...)

12:53 _rata_: good "morning"

12:53 ohpauleez: good morning

12:55 raek: _rata_: good morning (UGT)

12:58 _rata_: it's not really the morning here, but I'm just waking up... so it's my morning :)

13:01 Uppercut: Do Speakers´s Conj join in this channel?

13:06 raek: most of them hang around here, yes

13:07 _rata_: raek: I didn't know about UGT, great thing

13:07 raek: makes greetings a lot simpler :-)

13:19 polypus: this just tweeted: big ups to matt courtney of fgm (and #conjure!) for enabling recording talks.

13:19 guess they're recording, good to know.

13:21 _rata_: polypus, yes, they are recording :) I hope they upload them asap to do a mini-conj this weekend at home

13:22 rlb: What's the best way to detect eof from read, catch and check the exception, or create and pass in a unique eof token?

13:23 ...and if the latter, what's clojure's equivalent of (gensym)?

13:23 MayDaniel: rlb: (gensym)

13:23 rlb: MayDaniel: ahh, right -- just noticed.

13:24 So probably just (read false eof-token) where eof-token was generated via gensym.

13:25 raek: rlb: I often do something like (let [eof-token (Object.)] ...)

13:25 rlb: raek: that's what I was really asking -- what's the cheapest unique value.

13:25 raek: then just check for (= return-value eof-token)

13:26 rlb: I suppose (Object.) would probably be cheaper than (gensym).

13:26 Thanks

13:26 raek: another strategy would be to use a ns-quilified keyword

13:26 ,::eof-token

13:26 clojurebot: :sandbox/eof-token

13:46 _rata_: amalloy, I was finally kind of enlightened yesterday :)

13:46 amalloy: yeah?

13:46 glad you found my reference useful

13:48 _rata_: but it wasn't in monads... it was in closures

13:48 rlb: In guile it's possible to create an empty environment, and then populate it with only the bindings you want. Then you can call (eval form environment). Is something that possible in clojure?

13:48 In particular for sandboxing?

13:48 s/something that/something like that/

13:49 polypus: rlb: at the repl, try (in-ns foobar)

13:49 rlb: There's also a (safe-environment) that you can call and then adjust the result.

13:50 polypus: right, I know about namespaces, I'm just wondering if they could/would be secure.

13:50 polypus: (in-ns 'foobar) i mean. given that you haven't already populated foobar, it will be clear of most (all?) bindings. as far as secure, i have no idea

13:50 rlb: i.e. you probably have to remove or override ".", etc.

13:52 I'm just wondering about feasibility. Such an approach can be nice because you can build s-expression actions (based on user input or whatever), and then just eval them in the safe envt.

13:52 amalloy: rlb: you could probably find out by looking at the source for sexpbot or clojurebot

13:52 that's exactly what they do

13:52 polypus: amalloy: took the words right out of my mouth

13:52 rlb: amalloy: ahh, of course, excellent point -- I should have thought of that.

13:52 amalloy: clojurebot: source?

13:52 clojurebot: source is http://github.com/hiredman/clojurebot/tree/master

13:52 amalloy: $source

13:53 $ source

13:53 bah

13:53 rlb: That certainly answers my main "is it feasible" question. Thanks.

13:53 amalloy: rlb: neither of them is perfectly secure yet though. it should be possible, but every so often someone finds a hole

13:53 ,eval

13:53 clojurebot: #<core$eval clojure.core$eval@c40ed6>

13:54 nishant: is this the right place to ask questions about the clojure slime-repl?

13:54 rlb: Yeah, I suppose it doesn't *completely* answer the question, but they're certainly a good example of the problem.

13:55 amalloy: nishant: sure. if it's complicated internals-stuff, you may be better off asking technomancy, but here's good

13:57 _rata_: amalloy, http://gist.github.com/641036

13:57 nishant: amalloy: Sometimes, the repl doesn't remember command history, so when I type META-p it prints "no previous note", I don't remember ever enabling/disabling anything related to history, so not sure what's wrong.

13:58 amalloy: nishant: next time it happens check out what major/minor modes are active

14:00 it sounds like REPL mode may have gotten disabled somehow; M-p will look for notes and compile errors if it's not overridden by the REPL mode binding

14:01 nishant: amalloy: the mode text is (REPL Slime[clojure{local}])

14:02 amalloy: nishant: try M-x slime-repl-mode

14:03 (i'm not an expert in emacs or slime, just guessing here)

14:05 nishant: amalloy: thanks, I restarted emacs, and it switched to the right mode when I reconnected to swank

14:08 amalloy: _rata_: i don't see what you're getting at with this gist

14:10 _rata_: if I have a kappa agent, i can ask it with which kappa agent is it linked to through his site "x"

14:10 I just need that the last function call of each agent is called as-needed, not eagerly

14:11 amalloy, ^

14:13 amalloy: hm. so you're creating a function get-linked-agent, which closes around the source agent in order to create an agent which refers back to the source

14:14 _rata_: yes, that's it I think

14:14 nishant: ,dec

14:14 clojurebot: #<core$dec clojure.core$dec@1737301>

14:14 nishant: ,(dec 5)

14:14 clojurebot: 4

14:15 amalloy: but doesn't this have the same problem? a3 can't contain a function which closes around a3, because a3 doesn't exist yet

14:16 _rata_: no, that doesn't happen because the agent an agent closes around is parameterized

14:17 so they musn't exist at the moment you create the agent, you can "bind" them later

14:17 what does clojurebot when I ask him to evaluate (iterate inc 0)?

14:18 amalloy: _rata_: timeout

14:18 or possibly he prints the beginning then chokes on max message length

14:18 _rata_: ok

14:18 amalloy: at any rate you won't kill him with that

14:18 ,(range)

14:19 clojurebot: Execution Timed Out

14:19 _rata_: ok

14:20 is there something like Scheme's rec in clojure? (to create anonymous recursive closures)

14:21 raek: _rata_: (fn f [] ...)

14:21 _rata_: thanks :)

14:21 raek: in the anonymous function, f will refer to the function itself

14:22 btw, that is the only thing that (letfn [(f [] ...)] ...) does more than (let [f (fn [] ...)] ...)

14:23 _rata_: but (let [f (fn f [] ...)] ...) would be the same as the letfn expression

14:24 amalloy, so, the minimal example would be ((fn f1 [b] {:x (b f1)}) (fn f2 [b] {:x (b f2)}))

14:25 the return value of that is a kappa agent f1 linked to f2

14:26 and putting (fn f2 ...) at the beggining would return the kappa agent f2 linked to f1

14:27 is there anything like a lazy map?

14:28 amalloy: _rata_: not as a data structure. maps can't usefully be lazy like seqs

14:29 _rata_: amalloy, I know, it would be useful just for this case

14:29 :(

14:29 amalloy: _rata_: you want a lazy mapping from one seq to some other seq. that's what the map *function* does

14:31 _rata_: mmmm... so I would need ((fn f1 [b] {:x (map b [f1])}) ...)?

14:32 amalloy: i don't know. i'm still not convinced that what you're trying to do is really possible in an immutable context. you can dance around with laziness or closures, but in the end you need an object that refers to itself, which is a chicken/egg problem

14:33 i think the best you can do is have a global (or similar) map that tracks all the pointers, and have the agents themselves not know who they're next to without referring to the global map

14:36 _rata_: amalloy, you're probably right... but as you said me it was a common problem, I was trying to figure out a solution that's self-contained

14:41 shanmu: hi.. I am trying to use clojure.contrib.zip-filter.xml to extract a nodeset from an xml document.... is it possible?

14:41 when I use (xml->) without a final text, then I get a nested list of vector/ map /lists with the elements repeated multiple times

14:44 amalloy: shanmu: i did this just yesterday. lemme go find it for you

14:45 shanmu: amalloy: thanks a lot! I am trying to understand how zip works.. a bit too abstract for me now...

14:49 amalloy: https://gist.github.com/54446f11e4e3dd85f998

15:09 vibrant: hey ho!

15:09 anyone alive?

15:09 _rata_: hi vibrant

15:09 vibrant: hey rata

15:10 i'm trying to install penumbra, and i'm getting this error after running lein native-deps

15:10 Caused by: java.lang.IllegalAccessError: default-repos is not public

15:12 _rata_: http://gist.github.com/641036 <- why stack overflow? the delay seems to be not working

15:14 technomancy: vibrant: probably an old version of lein-deps; try 1.0.4

15:14 s/lein-deps/native-deps/

15:14 sexpbot: <technomancy> vibrant: probably an old version of native-deps; try 1.0.4

15:14 vibrant: i am using 1.0.4

15:15 i googled first and saw that bug/and the fix of it :)

15:15 but it didn't fix anything for me.

15:15 technomancy: =\

15:15 lein 1.3.1?

15:17 vibrant: now that i run it, it fails with an error

15:18 i mean lein by itself, let me see what's the reason..

15:19 1.1.0

15:19 :)

15:22 shanmu: amalloy: many thanks for the pointer!! zip/children was the function I was after to return the nodeset :)

15:23 vibrant: technomancy; now that i updated it works like a charm.

15:26 rlb: Is there a test like list? for a Cons?

15:26 Naively, I was surprised list? returned false there.

15:27 MayDaniel: rlb: seq?

15:28 rlb: Won't work in this case -- need to omit set, map, string, etc.

15:28 I just want to test if something's a vector, list, or cons.

15:29 I can always just use (instance? Cons x)...

15:32 MOOOO: f

15:32 fffLL: L

15:36 raek: rlb: 'seq?' tests if it is a ISeq. it is not the same as 'seq'

15:37 ,(seq? (cons 1 nil))

15:37 clojurebot: true

15:37 raek: ,(seq? {})

15:37 clojurebot: false

15:37 vibrant: humm... now i get this: Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (opengl.clj:9)

15:37 raek: ,(seq? (list 1))

15:37 clojurebot: true

15:37 amalloy: ,(seq? [])

15:37 clojurebot: false

15:38 amalloy: ,(seq? "")

15:38 clojurebot: false

15:38 amalloy: rlb: looks like seq? does what you want

15:38 raek: PersistentLists and what you get from a seq call are pretty much the only things for which seq? returns true

15:39 and conses, of course :-)

15:42 vibrant: are you sure you have matching clojure and penumbra versions?

15:43 vibrant: raek; well.. i'm using la clojure which supposedly uses 1.1, but i think i deleted it and added 1.2 to lib/

15:43 raek: clj 1.2 and penumbra 0.5 goes together

15:43 *clojure 1.1

15:44 and clojure 1.2 and penumbra 0.6 goes together

15:44 vibrant: http://github.com/ztellman/penumbra/wiki/getting-started

15:44 vibrant: yeah i thought i was using 1.2, but it seems that 1.1 is set on classpath by IDEA

15:44 so maybe I'll butcher that one and change it to 1.2?

15:44 inside IDEA

15:45 raek: does IDEA maintain different different classpaths for different projects?

15:46 I think the easiest way is to let lein download the right jars

15:46 vibrant: i think it does.

15:46 well is 0.5 old or crippled or something?

15:46 raek: and then tell the IDE to use all jars in the lib/ dir

15:46 vibrant: yea that's what it did

15:46 raek: no idea...

15:46 vibrant: but it still included clojure.jar from the plugin as first in the classpath

15:46 so now i switched it to 1.2 and let's see if it works :)

15:47 ok, now i get: Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path (slate.clj:9)

15:47 raek: codes compiled with different versions of clojure aren't compatible

15:47 fffLL: )

15:47 )

15:47 :)

15:48 raek: penumbra requires a lot of special libraries

15:48 well, some "native" libs

15:48 fffLL: what's penumbra anyway)

15:48 raek: opengl lib

15:48 fffLL: oh ok :P)

15:48 raek: vibrant: have you done a "lein native-deps"?

15:49 vibrant: yup, but it's not on java.library.path

15:49 i'm adding it

15:49 fffLL: I'm super stoked, I made my irc client

15:49 raek: fffLL: cool!

15:49 in clojure?

15:49 fffLL: typing this in repl as function calls :P

15:49 yes

15:50 this is tedious I have to make an UI for this

15:50 raek: did you base it on a library or did you roll your own?

15:50 fffLL: my own, it's really basic :)

15:51 doesn't do anything but sit in the channel and send messages

15:51 raek: it's fun that interfacing with IRC is very simple

15:51 vibrant: yea writing irc cliens/bots is great

15:51 i wrote one in C, C++, Perl

15:51 raek: Raynes wrote the irclj lib

15:51 I have been hacking on it too

15:52 vibrant: raek; now that I run tetris from the demos it says that process exited with exit code 0 :)

15:52 raek; but doesn't do anything

15:54 _rata_: http://gist.github.com/641036 <- why stack overflow? the (delay ...) seems to be not working

15:59 ymasory: how can i collect a list of characters into a string?

15:59 raek: vibrant: if you try to start the application with lein repl, you will get the error messages in a form that more persons in this channel are familiar with

16:00 (I have never used IDEA myself)

16:00 vibrant: raek; it seems that there is not error, it's just that nothing is being run (only the script is compiled)

16:00 s/not/no/

16:00 sexpbot: <vibrant> raek; it seems that there is no error, it's just that nohing is being run (only the script is compiled)

16:00 raek: vibrant: I think you launch the demo by require'ing its namespace

16:00 dakrone: ymasory: (apply str '(\a \b \c))

16:00 ymasory: dakrone: thank you

16:01 dakrone: ymasory: you're welcome

16:02 raek: vibrant: doing something like (require 'example.game.tetris) would perhaps work

16:02 vibrant: ok i got it. just did (start) at the end of the file.

16:02 amalloy: _rata_: delays are forced autmatically when you look at them in the repl

16:02 raek: but that file is in the test/ folder, which I'm not certain if it is on the classpath

16:02 vibrant: have to change it to some main func, i'm not experienced yet :)

16:02 so i'm playing tetris! wow!

16:02 raek: ok, great!

16:03 _rata_: mmmm ok, thanks again amalloy :)

16:03 amalloy: try (def x (delayed-func))

16:03 vibrant: raek; only it took a really long time to launch.

16:03 i wonder why.

16:05 MOOOO: how do declare stuff private again?

16:05 #^private but I don;t know where to put it

16:06 ,(defn #^private f [] nil)

16:06 clojurebot: DENIED

16:06 dakrone: MOOOO: you can use (defn- foo ...) or (def #^{:private true} ...)

16:06 raek: MOOOO: 1.1: (def #^{:private true} foo ...) 1.2 (def ^:private foo ...)

16:06 MOOOO: or with defn: defn-

16:06 MOOOO: how about a var

16:07 that is not a function

16:07 raek: either by adding metadata, or using clojure.contrib.def/defvar-

16:07 MOOOO: thank you

16:15 vibrant: raek; any idea why it takes like 17 seconds before the app window shows up?

16:15 is compilation so lengthy?

16:16 amalloy: vibrant: probably

16:17 vibrant: yea starting the repl takes 2 seconds

16:25 raek: vibrant: I think it is due to the libs penumbra use

16:26 vibrant: raek; taht's why compilation is long?

16:26 raek: I noticed one that when I had penumbra and its dependency jars on the classpath, clojure started much slower

16:27 I don't think it is the compilaiton

16:27 but I'm not certain about this at all

16:30 clojure source is only compiled when required

16:30 (unless it was AOT-compiled)

16:32 crowbar71: I wrote a fairly simple bot in clojure. it's using the pirc java lib though.

16:37 raek: clojurebot uses pirc too

16:41 vibrant: raek; well when i just start the repl with that big-ass classpath - it starts in 2 seconds

16:41 raek; but when i also add that tetris.clj to commandline it starts in 20

16:48 raek: vibrant: hrm, ok. then it sound more resonable that it is the compilation...

16:49 vibrant: raek; yea it's surprisingly slow.

16:49 dpritchett: i like your strangeloop slides chouser

16:50 KirinDave: Does anyone know if there is an easy way to add new lein commands from a project.clj?

16:50 raek: vibrant: you could ask the folks at the penumbra mail list. I'm sure this has been noticed before...

16:50 maharishi: can anyone tell me what this is called so I can find documentation on it: #(.startsWith % "A") is pound a macro here?

16:51 MayDaniel: It's a reader macro.

16:51 KirinDave: maharishi: It's the quick syntax for (fn [] ...)

16:51 raek: KirinDave: a lein command foo is just a function called foo in the namespace leiningen.foo . you can but that file in your src/ dir, or make it another project

16:52 KirinDave: raek: Is there an easy example of this somewhere?

16:52 technomancy: KirinDave: see the slides from the talk I just gave. =)

16:52 KirinDave: technomancy: I am not at the conj.

16:53 technomancy: Are your slides up?

16:53 technomancy: you can do (in-ns 'leiningen.mytask) (defn mytask [project] ...) inside project.clj but a separate file is cleaner

16:53 raek: KirinDave: I tested this once: http://gist.github.com/629745

16:53 amalloy: maharishi: #(.startsWith % "A") is shorthand for (fn [arg1] (.startsWith arg1 "A")). so you want to look at the javadoc for startsWith (which is in the java.lang.String class, as it happens)

16:53 technomancy: the slides arent that detailed: http://p.hagelb.org/conj-2010-slides.org.html

16:54 KirinDave: yeah I know. =(

16:54 vibrant: raek; normally it should be faster, right?

16:54 KirinDave: technomancy: haha, "slides"

16:54 raek: vibrant: 20 seconds is very slow

16:55 technomancy: KirinDave: well they certainly aren't film.

16:56 KirinDave: technomancy: Thnaks

16:56 dpritchett: i just installed epresent thanks to you technomancy ... i'm entertained so far

16:57 does it look better in xwindows or is it the regular console font there too?

16:57 technomancy: dpritchett: it's not polished, but it does everything I need.

16:57 it looks good in X; maybe M-x customize-face?

16:57 dpritchett: and it's perfect for an emerging language conference

16:57 technomancy: I don't know how the defaults look on OS X

16:58 dpritchett: the Factor talk at emerginglangs had slides written in Factor.

16:58 bonus points!

16:58 _schulte_: technomancy: no to push you away from that elegant solution, but org-mode has nice LaTeX Beamer publishing facilities :)

16:58 dpritchett: i'm looking at it in putty with my font set to consolas and it's fine i was just wondering if it had any gee-whiz graphics

16:59 maharishi: amalloy: KirinDave: MayDaniel: thanks

16:59 technomancy: _schulte_: I kind of thought you would say that. =) will check it out for next time.

16:59 mike5160: hi all

17:00 dpritchett: neat! $ ln -s swank-clojure.jar ~/.lein/plugins

17:01 ymasory: dumb question: is there an identity function?

17:01 _rata_: ymasory, yes, identity

17:01 ,identity

17:01 clojurebot: #<core$identity clojure.core$identity@8c530>

17:02 tonyl: ,(identity :ew)

17:02 clojurebot: :ew

17:02 ymasory: thank you

17:04 MOOOO: is there a way to combine :import and :requires in ns macro?

17:04 _schulte_: technomancy: actually, your epresent presentation looks surprisingly nice, if I find some free time I may adapt that to Org-mode

17:05 technomancy: MOOOO: import and require do pretty different things. use and require may be merged in the future, but import will always remain separate.

17:06 in other words, clojure vars are not classes

17:06 _schulte_: it's tromey's actually; he just handed it off to me.

17:07 _schulte_: technomancy: oh nice, either way anything fun in Emacs must be subsumed by Org-mode

17:08 technomancy: NOM

17:10 _rata_: is there any way to have a map that always applies a function before returning a value? something like ((weird-map inc {:a 1}) :a) -> 2

17:10 or do I need to extend a protocol or similar?

17:12 tonyl: _rata_ can a normal function just do it?

17:13 bhenry: _rata_ how about (defn weird-map [f m] (fn [k] (f (k m))))

17:14 ,(let [werid-map (fn [f m] (fn [k] (f (k m))))] ((weird-map inc {:a 1} :a)

17:14 clojurebot: EOF while reading

17:15 bhenry: ,(let [werid-map (fn [f m] (fn [k] (f (k m))))] ((weird-map inc {:a 1} :a))

17:15 clojurebot: EOF while reading

17:15 bhenry: grrr

17:15 https://gist.github.com/cee23f6bff8f33ee90f2

17:15 _rata_: ^

17:15 _rata_: bhenry, yes, that's it

17:16 bhenry: cool. with chouser focused on the conj i can get some answers in now.

17:16 _rata_: thanks :)

17:21 kevins: newbie quesion....what am I doing wrong here?

17:21 (take 10 (iterate rand-int 50))

17:22 user=>

17:22 (50 33 4 1 0 0 0 0 0 0)

17:22 user=>

17:22 (50 42 7 0 0 0 0 0 0 0)

17:22 user=>

17:22 (50 19 9 4 2 0 0 0 0 0)

17:22 seems like a lot of 0's for rand?

17:22 amalloy: kevins: repeatedly, not iterate

17:23 kevins: I just read the docs...but I'm not catching the difference...is there a quick explanation?

17:23 thanks (btw)

17:24 nDuff: kevins, it's using the result as each call as the argument to the next

17:24 bhenry: iterate is doing (rand-int (rand-int 50)) and so on

17:24 nDuff: kevins, so the ceiling for the random number drops each iteration

17:24 kevins: I see...cool thanks.

17:24 amalloy: _rata_, bhenry: you can do it this way and get an actual map back:

17:24 ,(let [remap (fn [f m] (into {} (map (fn [[k v]] {k (f v)}) m)))] (remap inc {:a 1 :b 3}))

17:24 clojurebot: {:a 2, :b 4}

17:28 _rata_: that doesn't work for me... I think because of chunking

17:28 I get a stack overflow

17:29 bhenry: (defn remap [f m]

17:29 (apply hash-map

17:29 (interleave (keys m)

17:29 (map f (vals m)))))

17:30 okay rich gets my undivided attention now.

17:30 MayDaniel: ,[(zipmap [1 2] [3 4]) (apply hash-map (interleave [1 2] [3 4]))]

17:30 clojurebot: [{2 4, 1 3} {1 3, 2 4}]

17:35 MayDaniel: ,(clojure.contrib.generic.functor/fmap inc {:a 1 :b 2})

17:35 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.generic.functor

17:38 _rata_: thank you all guys... see you later

17:39 ymasory: how does one append to the end of a sequence?

17:40 raek: ymasory: 1. use a vector or 2. use concat

17:41 replaca: technomancy: what's the right version of lein-swank to use these days? Is iit built in now?

17:42 ymasory: raek: thanks

17:42 raek: ymasory: you cannot modify the sequence to have something else at its end, but concat makes a lazy sequence that will traverse the sequences you give it

17:42 ymasory: right, but i have wrap the element i'm appending if i use concat

17:42 raek: ymasory: vectors are made to have efficient append to the back

17:43 if you do multiple concats, you end up having nested "concat objects"

17:43 ymasory: raek: right. i imagine there's a one-liner to copy a list into a vector?

17:43 raek: ymasory: yup. it is 'vec'

17:44 ymasory: thanks

17:44 isn't that a little awkward though? if i write a function that takes any sequence i now have to pass it off to a helper (after converting it to a vector) to make sure i don't linear time appends

17:47 cj_: , (map (fn [r] (* r r)) (range 1 10000)))

17:47 raek: how would you do a linear time append accidentally?

17:48 cj_: , (map (fn [r] (* r r)) (range 1 20)))

17:51 raek: if you need to build something sequential one item at a time, use a vector

17:51 if you need to glue together two sequences, use concat

17:53 cj_: me?

17:53 , (map (fn [r] (* r r)) (range 1 20))

17:53 where is clojurebot

17:54 amalloy: ,1

17:54 ->1

17:54 sexpbot: ⟹ 1

17:54 MayDaniel: ,(map (fn [r] (* r r)) (range 1 20))

17:57 Derander: -> (+ 1 1)

17:57 sexpbot: ⟹ 2

17:57 cj_: -> (map (fn [r] (* r r)) (range 1 20))

17:57 sexpbot: ⟹ (1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361)

17:58 cj_: -> (boolean (some #{25} (map (fn [r] (* r r)) (range 1 10000)))))

17:58 sexpbot: ⟹ true

17:59 cj_: -> (boolean (some #{25} (map (fn [r] (* r r)) (range 1 10000))) (str "True"))

17:59 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$boolean

18:00 cj_: -> (boolean (some #{31} (map (fn [r] (* r r)) (range 1 20))))

18:00 sexpbot: ⟹ false

18:01 cj_: -> (boolean (some #{31} (map (fn [r] (* r r)) (range 1 20))) (str "True"))

18:01 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$boolean

18:03 cj_: -> (if (= true (boolean (some #{numero} (map (fn [r] (* r r)) (range 1 10000))))) (str "square") )

18:03 sexpbot: java.lang.Exception: Unable to resolve symbol: numero in this context

18:03 cj_: -> (if (= true (boolean (some #{25} (map (fn [r] (* r r)) (range 1 10000))))) (str "square") )

18:03 sexpbot: ⟹ "square"

18:04 cj_: on ideon. i can´t see the result

18:05 raek: cj_: you can talk to clojurebot and sexpbot in private if you need to evaluate a lot of expressions

18:05 cj_: alright

18:06 raek: I'm not telling you to stop evaling code here, just that you have that option too

18:07 bsteuber: is it possible to build a variadic method using gen-class?

18:08 cj_: what (some) key does?

18:09 raek: ,(some odd? [2 4 6 7 8 10])

18:09 ->(some odd? [2 4 6 7 8 10])

18:09 sexpbot: ⟹ true

18:10 raek: ->(some #(if (odd? %) %) [2 4 6 7 8 10])

18:10 sexpbot: ⟹ 7

18:10 raek: some applies the function you give it to each element in turn and return the first result that is truthy

18:10 that is, non-nil and non-false

18:14 tensorpudding: -> (some #(= 4 (mod % 7)) (map #(* % %) (range 0 7)))

18:14 sexpbot: ⟹ true

18:14 raek: ->(some {:a 1, :b 2} [:x :y :z :a :b :c])

18:14 sexpbot: ⟹ 1

18:24 amalloy: Raynes: forget the conj, everyone's using sexpbot intead of clojurebot, you gotta see this

18:25 cj_: -> ( - (.getTime (java.util.Date.)) 10000)

18:25 sexpbot: java.lang.SecurityException: Code did not pass sandbox guidelines: ()

18:27 tensorpudding: is there a way to recurse in a lambda?

18:29 mattc: tensorpudding: yes, this is what the Y combinator does

18:29 raek: recur

18:29 tensorpudding: recur isn't strong enough for what i wanted

18:30 raek: you want to do a self call in a non-tail position?

18:31 tensorpudding: yes

18:31 Chousuke: you can name anonymous functions :P

18:31 (fn name ...)

18:32 then just (name) in the function

18:32 tensorpudding: oh, darn, i didn't know that

18:32 Chousuke: It doesn't come up very often :)

18:32 amalloy: -> (let [anon (fn f [i] (when-not (zero? i) (f (dec i))))] (anon 4))

18:32 sexpbot: ⟹ nil

18:33 amalloy: or i guess if you wanted it really anonymous, with no let:

18:33 ->((fn f [i] (when-not (zero? i) (f (dec i))))) 4)

18:33 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: box5645$eval5813$f

18:33 amalloy: blah, whatever, something like that

18:34 cj_: inside the (range 1 20) can I add a "if" to check a condition?

18:34 Chousuke: what do you mean?

18:35 raek: cj_: no, but you can use 'filter' or 'remove' to get a sequence of only some of the elements

18:37 tensorpudding: ugh, what's an ISeq

18:37 these error messages are no fun

18:37 polypus: cj_: or use for (for [i (range 1 20) :when (odd? i) ] i)

18:38 cj_: hmm I guess it works

18:38 raek: tensorpudding: a cons, an instance of IPeristentList, or anything you can get from a 'seq' call

18:39 in traditional Lisps, it would be just "list"

18:40 Chousuke: yeah error messages suck

18:41 fielcabral: Hi is there a way to start a java debugger from within slime? or is it necessary to start a separate debugger and load your code there?

18:44 replaca: fielcabral: I think you have to start slime with the java debugger enabled

18:46 fielcabral: okay thank you

18:49 KirinDave: I fiercely wish I had multiple return values from common lisp in Clojure right now.

18:53 replaca: KirinDave: you can throw metadata on the return value

18:53 lazy1: KirinDave: You can bind multiple values - (let [[x y] (f)] ...)

18:53 KirinDave: See http://codepad.org/fYbcrrKP

18:53 replaca: but I am usually just happy with destructuring the return value

18:53 as lazy1 says

18:53 KirinDave: lazy1: That's not multiple return values.

18:53 The problem is that the 1st return value might be anything, even a vector

18:54 replaca: Metadata is interesting, but this has to place nice with scala.

18:54 replaca: I think it was jochu who wrote a version with metadata a long time ago

18:54 KirinDave: Which is where the complexity comes in.

18:54 tensorpudding: -> (take 20 ((fn f [l] (if (nil? l) nil (let [y (first l)] (lazy-seq (cons y (f (filter #(> (mod % y) 0) (next l)))))))) (iterate inc 2)))

18:54 sexpbot: ⟹ (2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71)

18:54 replaca: KirinDave: well that's a whole other kettle of fish :)

18:54 KirinDave: replaca: Yeah.

18:54 So imagine a function is asked to return true, false, or an annotation and true or false.

18:55 tensorpudding: it's nice that clojure has laziness

18:55 KirinDave: I'm sort of left mandating that every return value basically be a APersistentMap of {:result ..., :annotations {}}

18:55 tensorpudding: even if you have to use lazy-seq to get it

18:56 KirinDave: tensorpudding: Controlled laziness is a little more practical than what Haskell is doing. At least, for now. :)

18:56 Chousuke: tensorpudding: it's kind of a "why not?" feature I think. since you're dealing with seqs anyway, dealing with lazy ones is not much more work :P

18:57 tensorpudding: That nearly-literal port of Haskell's one-liner fake-sieve-of-eratosthenes is about three times longer in clojure

18:57 KirinDave: tensorpudding: Because it's a literal port?

18:58 tensorpudding: actually, not really literal, because the haskell used a list comprehension

18:58 instead of filter

18:58 primes = sieve [2..] where sieve (p:xs) = p : sieve [x|x<-xs, x `mod` p > 0]

18:59 though now that i think about it, the nil? is vestigial

19:01 ymasory: why does seq? return false for a vector?

19:02 raek: ymasory: a vector is not a seq itself, but it is seqable

19:02 ymasory: meaning that (seq a-vector) will return a seq

19:02 tensorpudding: Haskell is orthogonal to Clojure, since it has syntax sugar, static typing and pattern matching, not just the obligatory laziness

19:02 ymasory: raek: thanks. is there something like a seqable? function

19:03 raek: I think there is in contrib

19:03 there is also coll?

19:03 ,(doc coll?)

19:04 ymasory: thanks

19:04 raek: ymasory: what do you want to detect?

19:04 ymasory: i don't know enough about clojure's collection system to answer that

19:04 just beginning

19:05 tensorpudding: so i heard that people are interested in making clojure work on clojure

19:05 instead of on the jvm

19:05 Chousuke: well

19:05 it would work on the JVM still

19:05 tensorpudding: oh

19:05 Chousuke: just be written in itself

19:05 tensorpudding: hmm

19:05 Chousuke: that could of course make it easier to port to other hosts.

19:06 tensorpudding: it'd be neat to port it to other targets though

19:06 like the clr, or llvm

19:06 Chousuke: There's ClojureCLR, but it's basically a reimplementation

19:07 clojurebot: (1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 729 784 841 900 961 1024 1089 1156 1225 1296 1369 1444 1521 1600 1681 1764 1849 1936 2025 2116 2209 2304 2401 2500 2601 2704 2809 2916 3025 3136 3249 3364 3481 3600 3721 3844 3969 4096 4225 4356 4489 4624 4761 4900 5041 5184 5329 5476 5625 5776 5929 6084 6241 6400 6561 6724 6889 7056 7225 7396 7569 7744 7921 8100 8281 8464 8649 883

19:07 ymasory: i'm interested in llvm. i don't know enough yet but i'd like to contribute to scala llvm

19:08 Chousuke: AFAIK in 1.2 the final bits needed for Clojure-in-Clojure to actually happen went in, but I'm not sure what's happening on that front right now.

19:08 clojurebot: (1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361)

19:08 true

19:08 (1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361)

19:08 1

19:08 tensorpudding: i am interested in llvm also, since clang is growing, and haskell's ghc has llvm codegen now, which will hopefully make it more portable

19:08 clojurebot: "([x]); Returns true if x implements IPersistentCollection"

19:08 Chousuke: clojurebot is clearing the backlock I see...

19:08 clojurebot: (1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361)

19:08 Derander: why'd clojurebot randomly spew numbers?

19:08 up above w/ the squares

19:08 oh

19:09 Chousuke: it sometimes lags like that.

19:09 no idea why

19:09 Derander: odd. network problems perhaps

19:09 Chousuke: backlog, too

19:09 Derander: yeah, maybe it gets a whole flood of messages at once

19:09 ,(range)

19:09 or stuff like that breaks it?

19:09 clojurebot: Execution Timed Out

19:10 Chousuke: nope :)

19:10 Derander: :-(

19:41 KirinDave: If I have defrecord'd something

19:42 how do I tell if an object of that given defrecord type?

19:42 Can I?

19:43 bsteuber: does anyone know from scratch in which source file rich implemented the . operator?

19:58 amalloy: bsteuber: i think it's in src/jvm/asm

19:58 bsteuber: thx

20:04 muschneider: how can i construct a map list of ten first sum of odd numbers, making a perfect square, example. (1, 4, 9,16...)

20:05 => (1 10) map (r => r*r) toKey

20:05 -> (1 10) map (r => r*r) toKey

20:05 sexpbot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

20:05 muschneider: -> (1 10) map (r => r*r)

20:05 sexpbot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

20:06 muschneider: -> (+ 1 10)

20:06 sexpbot: ⟹ 11

20:07 AWizzArd: muschneider: which odd number needs to be squared to result in 16?

20:07 muschneider: -> (+ 1 3 5 7)

20:07 sexpbot: ⟹ 16

20:08 muschneider: I want to do a data structure containing this numbers....

20:08 AWizzArd: maybe with iterate?

20:08 you could construct a sequence of all odd natural numbers

20:09 (iterate #(+ 2) 1)

20:09 #(+ % 2)

20:11 Chousuke: (into {} (filter (fn [[k v]] (square? v)) (zipmap (odd-numbers) (reductions + (odd-numbers))))) ; something like this

20:11 parens not counted :P

20:11 though, hm

20:11 you might not actually want to use maps :D

20:12 infinite seqs is not a problem, but infinite maps are

20:12 are*

20:13 you can replace zipmap with (map vector ...) and just put a (take 10 ...) before filter

20:22 amalloy: Chousuke: (comp square? val) seems nicer than that anon function there

20:22 muschneider: alright, how can i check if a numbers exists in results of this map (map (fn [r] (* r r)) (range 1 100))

20:23 amalloy: ,(some #{10} (range 1 100))

20:23 clojurebot: 10

20:23 amalloy: ,(some #{1000} (range 1 100))

20:23 clojurebot: nil

20:24 Chousuke: amalloy: hmm, true

20:24 amalloy: I don't use function composition much :)

20:24 amalloy: yeah, there are a lot of features in clojure. hard to use all of them often

20:25 until recently it hadn't occurred to me to use (fn [[k v]]) to iterate through maps; i was doing some horrible stuff like #(whatever (key %) (val %))

20:42 ,(map #((juxt vec (partial reduce +)) (->> (range) (filter odd?) (take %))) (range 1 11))

20:42 clojurebot: ([[1] 1] [[1 3] 4] [[1 3 5] 9] [[1 3 5 7] 16] [[1 3 5 7 9] 25] [[1 3 5 7 9 11] 36] [[1 3 5 7 9 11 13] 49] [[1 3 5 7 9 11 13 15] 64] [[1 3 5 7 9 11 13 15 17] 81] [[1 3 5 7 9 11 13 15 17 19] 100])

20:43 amalloy: but i guess he's gone

21:00 Anniepoo_: how's the conj?

21:46 cjj: => (map #(* % %) (range 1 10))

21:46 -> (map #(* % %) (range 1 10))

21:46 sexpbot: ⟹ (1 4 9 16 25 36 49 64 81)

21:56 amalloy: cjj: are you the one who was trying to do the sum-of-odd-integers thing earlier?

21:57 cjj: all my class here

21:57 one alumn of university spreaded this channel

21:57 amalloy: ah

22:06 cjj: but this was me here, just a little early today the teacher joined too, probably soon more will too by mailling right now

22:07 this homework is a exam

22:07 lol

22:57 kevins: playing around with for and assoc.....I don't think I have building a map correct yet.

22:57 (def props (for [prop (System/getProperties)]

22:57 (assoc {} (. prop getKey) (. prop getValue))))

22:57 (get props "java.vm.name" "nope")

22:57 gives me nope...

22:59 ,(+ 1 1)

22:59 clojurebot: 2

23:04 amalloy: kevins: (assoc {} ...) builds a new map each time, with one key/value pair, and adds all those maps to a single list

23:05 kevins: I see. so I'm pretty much getting a map of one?

23:05 amalloy: so props will look like ({"name" "kevin"} {"OS" "Unix"}) or whatever

23:06 kevins: ah...a list of single maps.

23:06 amalloy: exactly

23:06 check into: it's perfect for things like this

23:06 ,(doc into)

23:06 clojurebot: "([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."

23:06 amalloy: ,(into {} [1 2 3 4])

23:06 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

23:06 amalloy: ,(into {} [[1 2] [3 4]])

23:06 clojurebot: {1 2, 3 4}

23:07 kevins: cool. Let me give that a try.

23:11 amalloy: kevins: i'm semi-afk, but happy to help; include my nick in your message and i'll hop back in

23:36 dakrone: so, everyone that's here enjoying the conj so far?

23:41 amalloy: the conjugates are probably still out partying

23:42 dakrone: suppose so

23:44 amalloy: check back in three hours :)

23:55 yousef: hello, sorry if this has been asked before but, can any one recommend either an online resource or book on clojure for someone who has done neither lisp or java. I mean, I've done java but nothing beyond really basic stuff i.e. loops, conditionals, input/output etc.

23:55 the books ive found usually cater to people with prior lisp or java experience :(

23:56 amalloy: yousef: you might try Structure and Interpretation of Computer Programs

23:56 it's a scheme book, not a clojure book, but it's an excellent introduction to the lisp family

23:57 http://mitpress.mit.edu/sicp/full-text/book/book.html

23:59 yousef: amalloy: ah thank you. i also considered the route of learning another dialect before clojure. apologies for my forgetfulness

Logging service provided by n01se.net