Re: multiple return values

2011-12-12 Thread Tom Faulhaber
Razvan, I think that you can implement your idea of "extending the class with proxy" in the following way (originally suggested to me by Rich Hickey & Chris Houser for use with the pretty printer): (let [extra-fields (ref {:field1 extra-value1, :field2 extra-value2}] (proxy [Writer IDeref]

Re: Lazy-seq of a binary file

2011-12-12 Thread Cedric Greevey
You also probably want more efficiency. Try something closer to: (defn lazy-reader [filename] (let [rd (fn [rdr] (let [buf (char-array 4096) n (.read rdr buf 0 4096)] (condp == n -1 (.close rdr) 0 (recur rdr)

Re: xml-zip

2011-12-12 Thread Tom Faulhaber
Hi Linus, Zippers and their associated helpers are woefully undocumented, so I'm not surprised you fell into the swamp. I think that the help you're looking for can be found in the clojure.data contrib project (see https://github.com/clojure/data.zip for the source and http://clojure.github.com/d

Re: Lazy-seq of a binary file

2011-12-12 Thread Stephen Compall
On Mon, 2011-12-12 at 20:03 -0800, Simone Mosciatti wrote: > Any suggest of how fix that ? In general, avoid loop. Specifically, try using letfn or (fn SOME-NAME-HERE [args...] ...) as your recursion target. -- Stephen Compall ^aCollection allSatisfy: [:each|aCondition]: less is better -- You

Re: Lazy-seq of a binary file

2011-12-12 Thread Simone Mosciatti
Ok, I found a possible problem, if i try to put all together, so write something like this: (defn lazy-reader [filename] (with-open [fl (clojure.java.io/reader filename)] (loop [bite (.read fl)] (lazy-seq (cons (bite) (recur (.read fl))) Obviously doesn't work... Any su

Re: multiple return values

2011-12-12 Thread Stephen Compall
On Mon, 2011-12-12 at 10:54 -0800, Razvan Rotaru wrote: > - function returns a value which is a java instance (not possible to > change here, or at least not from what I see - it needs to be a java > instance) > - i need to be able to call some function which gets some values that > are not part of

Re: multiple return values

2011-12-12 Thread Alex Baranosky
Intuitively it sounds like you are making something much more complicated than it needs to be. I'd say to return from your computation a vector with the two values, or possibly a map with them. If you need to create some kind of Java interop object, then map the result of the computation to that

Re: multiple return values

2011-12-12 Thread Kevin Downey
On Mon, Dec 12, 2011 at 10:54 AM, Razvan Rotaru wrote: > Hi, > > I read that there's no such thing as lisp-like multiple values return > in clojure. We can use vectors, and the destructuring feature helps > also. > > However, for what I'm trying to do I need to emulate somehow the > following beha

Re: multiple return values

2011-12-12 Thread James Reeves
On 12 December 2011 18:54, Razvan Rotaru wrote: > - function returns a value which is a java instance (not possible to > change here, or at least not from what I see - it needs to be a java > instance) Why does it need to be a Java instance? - James -- You received this message because you are

multiple return values

2011-12-12 Thread Razvan Rotaru
Hi, I read that there's no such thing as lisp-like multiple values return in clojure. We can use vectors, and the destructuring feature helps also. However, for what I'm trying to do I need to emulate somehow the following behavior: - function returns a value which is a java instance (not possibl

Re: Opposite function to cons, but in terms of construction, not destruction.

2011-12-12 Thread Michael Jaaka
Thanks to all for responses. I just wanted to use that in higher-order composition in mind, not to construct any data structures. I have tweaked a bit the function: (defn conr[ col item ] (lazy-seq (if (seq col) (cons (first col) (conr (rest col) ite

Re: Lazy-seq of a binary file

2011-12-12 Thread Simone Mosciatti
I thought to just put it into a take... (take number-of-byte-necessary (lazy-reader (clojure.java.io/reader "path/to/file"))) On Dec 12, 12:34 pm, Stephen Compall wrote: > On Mon, 2011-12-12 at 10:21 -0800, Simone Mosciatti wrote: > > (defn lazy-reader [fl] > >     (lazy-seq > >         (cons (.

Re: Lazy-seq of a binary file

2011-12-12 Thread Stephen Compall
On Mon, 2011-12-12 at 10:21 -0800, Simone Mosciatti wrote: > (defn lazy-reader [fl] > (lazy-seq > (cons (.read fl) (lazy-reader fl > > Can work ? (0.03696 ms for 500 char) > Possible problem ? You need a termination case; your lazy-reader currently always yields an infinite sequen

Re: Lazy-seq of a binary file

2011-12-12 Thread Simone Mosciatti
If I do just something like that: (def fl (clojure.java.io/reader "/path/to/file")) (defn lazy-reader [fl] (lazy-seq (cons (.read fl) (lazy-reader fl Can work ? (0.03696 ms for 500 char) Possible problem ? On Dec 11, 9:49 pm, Stephen Compall wrote: > On Sat, 2011-12-10 at 23:13

Re: core.match feature request: supporting java.util.HashMap

2011-12-12 Thread Takahiro
David Thanks. Nice design! (extend-type java.util.HashMap ma/IMatchLookup (val-at* [this k not-found] (or (.get this k) not-found))) 2011/12/13 David Nolen : > You can extend-type to IMatchLookup. > > David > > > On Mon, Dec 12, 2011 at 10:56 AM, Takahiro Hozumi > wrote: >> >>

ANN: Midje 1.3.0

2011-12-12 Thread Brian Marick
Midje 1.3's most important feature is compatibility with Clojure 1.3. https://github.com/marick/Midje Midje is a test framework for Clojure that supports top-down as well as bottom-up testing, encourages readable tests, provides a smooth migration path from clojure.test, supports a balance betw

Re: core.match feature request: supporting java.util.HashMap

2011-12-12 Thread David Nolen
You can extend-type to IMatchLookup. David On Mon, Dec 12, 2011 at 10:56 AM, Takahiro Hozumi wrote: > Hi, > > I'd like to use core.match with java.util.HashMap without converting > into {}. > The core.match doesn't support it as below. > > (let [m (java.util.HashMap. {"a" 1})] >(match m >

core.match feature request: supporting java.util.HashMap

2011-12-12 Thread Takahiro Hozumi
Hi, I'd like to use core.match with java.util.HashMap without converting into {}. The core.match doesn't support it as below. (let [m (java.util.HashMap. {"a" 1})] (match m {"a" 1} true)) ;=> nil Is it difficult? Thanks. -- You received this message because you are subscribe

xml-zip

2011-12-12 Thread Linus Ericsson
Hello! What's the clever way to read the E-tags "thisone" and "andthis" in the XML-file below given I don't know their id on beforehand? bla bla bla bla My solution so far would be something like (def mz (zip/xml-zip (xml/parse "dataabove.xml")

Re: Lazy-seq of a binary file

2011-12-12 Thread Stuart Sierra
It's hard to do this efficiently, unfortunately. See my notes & comments on http://dev.clojure.org/display/design/Byte+Sequences I did experiment with creating "chunked" binary sequences once, but never had time to finish it. -S -- You received this message because you are subscribed to the G

Re: Working Slackware Linux / emacs 23.3.1 / lein 1.6.2 / swank-1.4.0 / clj 1.3.0 REPL

2011-12-12 Thread David Brunell
I found that clojure-jack-in worked fine for me once I installed the latest clojure-mode from Marmalade. Don't use the one in the gnu repo. Be sure to use the package.el linked to on the marmalade-repo.org home page in order to access the repo. On Dec 11, 2011 10:11 PM, "Richard "Tiger" Melville

Re: Working Slackware Linux / emacs 23.3.1 / lein 1.6.2 / swank-1.4.0 / clj 1.3.0 REPL

2011-12-12 Thread C. Arel
Just do like this: 1.clone https://github.com/technomancy/clojure-mode.git into preferred directory e.g ./~git. add (add-to-list 'load-path "~/git/clojure-mode") (require 'clojure-mode) to .emacs 2.Install leiningen 3.(from terminal) lein plugin install swank-clojure 1.3.3 4.(from terminal )

Re: casting spels in clojure problem

2011-12-12 Thread Kevin Ilchmann Jørgensen
If this is your code: http://www.lisperati.com/clojure-spels/code.html Then (spel-print (describe-paths 'living-room game-map)) will work. spel-print takes a list that is returned from describe-paths. /Kevin On Mon, Dec 12, 2011 at 7:51 AM, jayvandal wrote: > I am trying castin spels in cloju