why does this work?

2009-01-23 Thread zoglma...@gmail.com
This is just something contrived I was playing around with and I know it is silly. I just have a couple of questions about it. (defn create-a [firstName lastName] (defn getFirstName [] firstName) (defn getLastName [] lastName) (fn [operator & operands] (apply operator operands))) (def

Re: why does this work?

2009-01-23 Thread zoglma...@gmail.com
Hi Achim, I think I understand now. > It's important to note that, regardless of the lexical context, def(n)   > creates global/top-level definitions (contrary to scheme, i believe). > (defn create-a [firstName lastName] (defn getFirstName [] firstName) (defn getLastName [] lastName) (fn

Re: why does this work?

2009-01-23 Thread zoglma...@gmail.com
Thanks Chouser, No, I really didn't have any intentions with this example. I was merely exploring around. In hindsight it is also obvious why this works. (defn foo[] (defn bar [x] (* x 2)) nil) (foo) (bar 2)---> returns 4 I just didn't realize initially what was going on... that defn bi

time complexity for immutable priority queue?

2009-02-28 Thread zoglma...@gmail.com
After helping tutor some students earlier in the week on the subject of priority queues, I ended up implementing it in Clojure as a mutable data structure. It was straight forward, but curiosity struck and I implemented the priority queue as an immutable data structure. I'm pretty sure that 'ffirs

Re: time complexity for immutable priority queue?

2009-03-01 Thread zoglma...@gmail.com
3, :prio 4, :count 1, :rest nil} > user=> (def pq (prio-insert pq 2 10)) > #'user/pq > user=> pq > {:first 2, :prio 10, :count 2, :rest {:first 3, :prio 4, :count   > 1, :rest nil}} > user=> (def pq (prio-insert pq 4 1)) > #'user/pq > user=> pq > {:firs

contrib mmap/duck_streams for binary data

2009-03-22 Thread zoglma...@gmail.com
While playing around and implementing straight up Humman compression, I wrote a handful of utilities to conveinently play with byte and bit streams because I didn't see anything too helpful in the mmap and duck_stream files. What I wrote would need to be changed to better work with the existing c