Re: ANN: Mid November 2012 London Clojure Dojo at Forward

2012-11-15 Thread Paul Lam
I'm going to tag along and tinker with Incanter in the office. Would love 
some help if anyone else is interested.



On Thursday, November 8, 2012 9:58:28 PM UTC, Bruce Durling wrote:

 Roll up! Roll up!

 On 19 November at 7PM hosted by our friends Forward in Camden is the next 
 London Clojure Dojo!

 http://mid-november-2012-ldnclj-dojo.eventbrite.co.uk/

 Food! Beer! Clojure!

 I hope to see you all there!


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: [ldnclj] Re: ANN: Mid November 2012 London Clojure Dojo at Forward

2012-11-15 Thread Bruce Durling
Sounds good to me. You could always write that one up on the whiteboard on
Monday. ;-)

cheers,
Bruce


On Thu, Nov 15, 2012 at 9:38 AM, Paul Lam paul@forward.co.uk wrote:

 I'm going to tag along and tinker with Incanter in the office. Would love
 some help if anyone else is interested.



 On Thursday, November 8, 2012 9:58:28 PM UTC, Bruce Durling wrote:

 Roll up! Roll up!

 On 19 November at 7PM hosted by our friends Forward in Camden is the next
 London Clojure Dojo!

 http://mid-november-2012-**ldnclj-dojo.eventbrite.co.uk/http://mid-november-2012-ldnclj-dojo.eventbrite.co.uk/

 Food! Beer! Clojure!

 I hope to see you all there!

  --
 You received this message because you are subscribed to the Google Groups
 London Clojurians group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/london-clojurians/-/RYcNTQQCvn8J.

 To post to this group, send email to london-clojuri...@googlegroups.com.
 To unsubscribe from this group, send email to
 london-clojurians+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/london-clojurians?hl=en.




-- 
@otfrom | CTO  co-founder @MastodonC | mastodonc.com

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

[lein-cljsbuild] exclude a cljs from compilation

2012-11-15 Thread Giacomo Cosenza
Hi all,
my question is the following:

- I like to have the usual brepl connect to the browser during development
- I like to have the same source-base (e.g. :source-path src/cljs) for both 
the development and production builds (e.g. :builds {:prod {.} {:dev 
{.} of :cljsbuild keyword)

Is there a way in lein-cljsbuild to reach this goal? I'd like to write 
something like this in :prod build

(defproject

  :cljsbuild {:builds
  {:dev {:source-path src/cljs
 :compiler :output-to 
resources/public/js/main_debug.js
   :optimizations :whitespace
   :pretty-print true}}
:prod {:source-path src/cljs
;;; here a key/values to exclude some file in 
:source-path from compilation, something like :exclude [afil.cljs 
another-file.cljs]
:compiler :output-to resources/public/js/main.js
   :optimizations :advanced}})


Thanks for the attention

Mimmo

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


core.logic matche with maps

2012-11-15 Thread MHOOO
Hello everybody,

recently I was using the following pattern a lot, in order to get access to 
a value inside a map:

(defn map-geto* [m k v]
(matche [m]
   ([[[k v] . _]])
   ([[_ . tail]] (map-geto* tail k v


I can use that like this:

(run* [q] (map-geto* (seq {:key value}) :key q))


which return (value). But after some thought I realized that I am 
essentially doing a linear-search on the map instead of leveraging the 
advantage of maps: fast-lookup of a value for a key.
So I wanted to ask: does anybody know of a way to re-write this function, 
so it uses map-destructuring instead, while still being general enough so 
it can be used on a map with any data?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Difference between JVM and CLR when destructuring a lazy sequence

2012-11-15 Thread ffailla
I believe I have discovered differing behavior between the JVM and CLR 
implementations when running the following statement:

user (let [foo (repeatedly (fn [] (let [r (rand)]
(println in-repeat:  r)
r)))
 [f  rst] foo]
 (println return:  f))

When run on the JVM with clojure 1.4.0, I get the following output:

in-repeat:  0.6929552277817549
in-repeat:  0.7005322422752974
return:  0.6929552277817549
nil
user 

When run on the CLR with clojure-clr 1.4.0, the random number will be 
printed from in-repeat infinitely, never to return.

Is this difference between the JVM and CLR implementations when 
destructuring a lazy sequence known?  

Also, why was the random number printed twice on the JVM side.  I haven't 
looked an the implementation, but I would guess this would be due to 
chunking the sequence. Thanks.

-Frank Failla 

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ClojureScript; How to set a field in an external JS library?

2012-11-15 Thread Thomas
Hi,

I have an external JS library I want to use and I can call methods on 
objects from the external library successful, but how do I set fields of on 
external library?

Do I need to put this in an externs.js file? and if yes, how exactly?

If I do this:

 (let [msg (js/Messaging.Message. hello world) ] 
(js/console.log msg)
   (.-destinationName msg test-topic)

I get this error:

Compiling resources/public/js/cljs.js failed:
java.lang.Error: Unknown dot form of (. msg -destinationName 
(test-topic)) with classification [:cljs.analyzer/expr 
:cljs.analyzer/property :cljs.analyzer/expr]

And I can see msg in the console with its various fields.

TIA,

Thomas

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ClojureScript; How to set a field in an external JS library?

2012-11-15 Thread Pierre-Henry Perret
Perhaps this thread can help : javascript 
propertieshttps://groups.google.com/d/msg/clojure/P6fK5KsShs8/hJaAbIGo5FYJ

Le jeudi 15 novembre 2012 17:26:33 UTC+1, Thomas a écrit :

 Hi,

 I have an external JS library I want to use and I can call methods on 
 objects from the external library successful, but how do I set fields of on 
 external library?

 Do I need to put this in an externs.js file? and if yes, how exactly?

 If I do this:

  (let [msg (js/Messaging.Message. hello world) ] 
 (js/console.log msg)
(.-destinationName msg test-topic)

 I get this error:

 Compiling resources/public/js/cljs.js failed:
 java.lang.Error: Unknown dot form of (. msg -destinationName 
 (test-topic)) with classification [:cljs.analyzer/expr 
 :cljs.analyzer/property :cljs.analyzer/expr]

 And I can see msg in the console with its various fields.

 TIA,

 Thomas


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ClojureScript; How to set a field in an external JS library?

2012-11-15 Thread Frank Siebenlist
Try:

(set! (.-destinationName msg) test-topic)

http://himera.herokuapp.com/index.html

-FS.



On Nov 15, 2012, at 11:26 AM, Thomas th.vanderv...@gmail.com wrote:

 Hi,
 
 I have an external JS library I want to use and I can call methods on objects 
 from the external library successful, but how do I set fields of on external 
 library?
 
 Do I need to put this in an externs.js file? and if yes, how exactly?
 
 If I do this:
 
  (let [msg (js/Messaging.Message. hello world) ] 
 (js/console.log msg)
(.-destinationName msg test-topic)
 
 I get this error:
 
 Compiling resources/public/js/cljs.js failed:
 java.lang.Error: Unknown dot form of (. msg -destinationName (test-topic)) 
 with classification [:cljs.analyzer/expr :cljs.analyzer/property 
 :cljs.analyzer/expr]
 
 And I can see msg in the console with its various fields.
 
 TIA,
 
 Thomas
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript; How to set a field in an external JS library?

2012-11-15 Thread Thomas
Thank you Frank!!! That did the trick (DOH)

Thomas

On Thursday, November 15, 2012 4:40:53 PM UTC, FrankS wrote:

 Try: 

 (set! (.-destinationName msg) test-topic) 

 http://himera.herokuapp.com/index.html 

 -FS. 



 On Nov 15, 2012, at 11:26 AM, Thomas th.van...@gmail.com javascript: 
 wrote: 

  Hi, 
  
  I have an external JS library I want to use and I can call methods on 
 objects from the external library successful, but how do I set fields of on 
 external library? 
  
  Do I need to put this in an externs.js file? and if yes, how exactly? 
  
  If I do this: 
  
   (let [msg (js/Messaging.Message. hello world) ] 
  (js/console.log msg) 
 (.-destinationName msg test-topic) 
  
  I get this error: 
  
  Compiling resources/public/js/cljs.js failed: 
  java.lang.Error: Unknown dot form of (. msg -destinationName 
 (test-topic)) with classification [:cljs.analyzer/expr 
 :cljs.analyzer/property :cljs.analyzer/expr] 
  
  And I can see msg in the console with its various fields. 
  
  TIA, 
  
  Thomas 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Proposed change to let- syntax

2012-11-15 Thread Alex Nixon
Hi all,

I find the proposed function let- in Clojure 1.5 very useful, but a bit
ugly.  The arguments are backwards when compared to vanilla let, and it
doesn't support destructuring where it easily could (which I believe would
be helpful when threading 'state-like' maps, as I find let- very useful
for).

I'd like to float an alternative implementation which improves on both
these issues.  Thoughts?

(defmacro new-let-
  Establishes bindings as provided for let, evaluates the first form
   in the lexical context of that binding, then re-establishes bindings
   to that result, repeating for each successive form
  [bindings  forms]
  (assert (vector? bindings) binding must be a vector)
  (assert (= 2 (count bindings)) binding vector must contain exactly two
forms)
  `(let [~@bindings
 ~@(interleave (repeat (bindings 0)) (drop-last forms))]
 ~(last forms)))

(new-let- [{:keys [foo bar] :as state} {:foo 1 :bar 2}]
  (assoc state :foo (inc bar))
  (assoc state :bar (inc foo))) ; = {:foo 3, :bar 4}

-- 
*Alex Nixon*

Software Engineer | SwiftKey

*a...@swiftkey.net** | http://www.swiftkey.net/*

++
WINNER - MOST INNOVATIVE MOBILE
APPhttp://www.swiftkey.net/swiftkey-wins-most-innovative-app-at-mwc
 - GSMA GLOBAL MOBILE AWARDS 2012

Head office: 91-95 Southwark Bridge Road, London, SE1 0AX TouchType is a
limited company registered in England and Wales, number 06671487.
Registered office: 91-95 Southwark Bridge Road, London, SE1 0AX

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Difference between JVM and CLR when destructuring a lazy sequence

2012-11-15 Thread Alan Malloy
Binding to [ rst] must realize an element of the sequence, to determine if 
there are any left, and it promises to never bind (), only nil.

On Thursday, November 15, 2012 7:23:05 AM UTC-8, ffailla wrote:

 I believe I have discovered differing behavior between the JVM and CLR 
 implementations when running the following statement:

 user (let [foo (repeatedly (fn [] (let [r (rand)]
 (println in-repeat:  r)
 r)))
  [f  rst] foo]
  (println return:  f))

 When run on the JVM with clojure 1.4.0, I get the following output:

 in-repeat:  0.6929552277817549
 in-repeat:  0.7005322422752974
 return:  0.6929552277817549
 nil
 user 

 When run on the CLR with clojure-clr 1.4.0, the random number will be 
 printed from in-repeat infinitely, never to return.

 Is this difference between the JVM and CLR implementations when 
 destructuring a lazy sequence known?  

 Also, why was the random number printed twice on the JVM side.  I haven't 
 looked an the implementation, but I would guess this would be due to 
 chunking the sequence. Thanks.

 -Frank Failla 


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

How to write this in idiomatic Clojure code?

2012-11-15 Thread Hussein B.
Hi,

Would you please help me to morph this to an idiomatic Clojure ?

(defn crazy [input]
(if (instance? SomeClass input)
(seq (process-some-class-instance input))
(map  crazy  (:children input


Thanks for help and time.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: How to write this in idiomatic Clojure code?

2012-11-15 Thread Jay Fields
That code is clear enough that I wouldn't feel obligated to change it
if I encountered it.

You could also

(defmulti crazy class)

(defmethod crazy SomeClass [input]
  (seq (process-some-class-instance input))

(defmethod crazy :default [{:keys [children]}]
  (map crazy children))

On Thu, Nov 15, 2012 at 5:33 PM, Hussein B. hubaghd...@gmail.com wrote:
 Hi,

 Would you please help me to morph this to an idiomatic Clojure ?

 (defn crazy [input]
 (if (instance? SomeClass input)
 (seq (process-some-class-instance input))
 (map  crazy  (:children input


 Thanks for help and time.

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Proposed change to let- syntax

2012-11-15 Thread Mark Engelberg
Where did you find the proposal?  I can't find any info about let-

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: code waiting on something - cannot debug - driving me insane!!!

2012-11-15 Thread Karsten Schmidt
Hi Jim, isn't that just due to the fact that closing the Swing frame
kills the nrepl server JVM, but not the REPL client?

Also discussed here:
https://groups.google.com/forum/?fromgroups=#!topic/leiningen/QLcZIK2e5C0

I agree, it's annoying, but not sure how to workaround it? Maybe with
a heartbeat between nrepl client/server with the client closing the
repl session if the heartbeat been missing for x seconds...

Hth! K.


On 13 November 2012 23:25, Jim - FooBar(); jimpil1...@gmail.com wrote:
 The original project is already on github...I just committed the dummy
 namespace as well so you can have a look...
 so, do:

 git clone https://github.com/jimpil/Clondie24.git
 cd Clondie24
 lein2 repl

 (load-file Clondie24.games.dummy.clj)
 (ns Clondie24.games.dummy)
 (-main)

 then close the frame without doing anything and try evaluating anything (e.g
 (:name details)).
 it goes without saying that the same thing happens in all other proper games
 as well...

 thanks a million for looking into this :-)

 Jim



 On 13/11/12 22:35, Laurent PETIT wrote:

 Could you create a small lein2 project on github with what you
 previously pasted in this thread correctly spread over files, etc., so
 that it's really quick to reproduce the error?

 Thanks,

 Laurent

 Sent from a smartphone, please excuse the brevity/typos.

 Le 13 nov. 2012 ą 22:52, Jim - FooBar(); jimpil1...@gmail.com a écrit
 :

 On 13/11/12 21:45, Dave Ray wrote:

 Dump the JVM's threads [1] and see what it's stuck on?

 What am I looking for? I don't see anything related with my project...IT
 is pretty obvious from the output though that everything is waiting! No clue
 what though...

 Jim

 -

 2012-11-13 21:47:16
 Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.2-b09 mixed mode):

 Thread-11 prio=10 tid=0x7f4268022800 nid=0x1fc8 waiting on
 condition [0x7f4258338000]
java.lang.Thread.State: TIMED_WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  0xc286d270 (a
 java.util.concurrent.SynchronousQueue$TransferStack)
 at
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
 at
 java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
 at
 java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
 at
 java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
 at
 clojure.tools.nrepl.transport$fn_transport$fn__1008.invoke(transport.clj:41)
 at clojure.tools.nrepl.transport.FnTransport.recv(transport.clj:28)
 at reply.eval_modes.nrepl$main$fn__1451.invoke(nrepl.clj:154)
 at clojure.lang.AFn.run(AFn.java:24)
 at java.lang.Thread.run(Thread.java:722)

 NonBlockingInputStreamThread daemon prio=10 tid=0x7f42685d9000
 nid=0x1fc5 in Object.wait() [0x7f4258439000]
java.lang.Thread.State: WAITING (on object monitor)
 at java.lang.Object.wait(Native Method)
 - waiting on 0xc286b100 (a
 jline.internal.NonBlockingInputStream)
 at
 jline.internal.NonBlockingInputStream.run(NonBlockingInputStream.java:278)
 - locked 0xc286b100 (a
 jline.internal.NonBlockingInputStream)
 at java.lang.Thread.run(Thread.java:722)

 process reaper daemon prio=10 tid=0x7f42685d5000 nid=0x1fbf waiting
 on condition [0x7f4258461000]
java.lang.Thread.State: TIMED_WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  0xc286d7e8 (a
 java.util.concurrent.SynchronousQueue$TransferStack)
 at
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
 at
 java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
 at
 java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
 at
 java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
 at
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
 at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
 at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
 at java.lang.Thread.run(Thread.java:722)

 clojure-agent-send-off-pool-3 prio=10 tid=0x7f4214005000 nid=0x1fbd
 runnable [0x7f425856]
java.lang.Thread.State: RUNNABLE
 at java.net.PlainSocketImpl.socketAccept(Native Method)
 at
 java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:398)
 at java.net.ServerSocket.implAccept(ServerSocket.java:522)
 at java.net.ServerSocket.accept(ServerSocket.java:490)
 at clojure.tools.nrepl.server$accept_connection.invoke(server.clj:32)
 at clojure.core$binding_conveyor_fn$fn__3989.invoke(core.clj:1822)
 at clojure.lang.AFn.applyToHelper(AFn.java:161)
 at 

Re: Proposed change to let- syntax

2012-11-15 Thread Andy Fingerhut
Check git commit logs from a month or so ago.  Rich Hickey committed it.

Andy

Sent from my iPhone

On Nov 15, 2012, at 2:41 PM, Mark Engelberg mark.engelb...@gmail.com wrote:

 Where did you find the proposal?  I can't find any info about let-
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: How to write this in idiomatic Clojure code?

2012-11-15 Thread Hussein B.
The snippet I provided, is an idiomatic Clojure ?

On Friday, November 16, 2012 12:41:31 AM UTC+2, Jay Fields wrote:

 That code is clear enough that I wouldn't feel obligated to change it 
 if I encountered it. 

 You could also 

 (defmulti crazy class) 

 (defmethod crazy SomeClass [input] 
   (seq (process-some-class-instance input)) 

 (defmethod crazy :default [{:keys [children]}] 
   (map crazy children)) 

 On Thu, Nov 15, 2012 at 5:33 PM, Hussein B. hubag...@gmail.comjavascript: 
 wrote: 
  Hi, 
  
  Would you please help me to morph this to an idiomatic Clojure ? 
  
  (defn crazy [input] 
  (if (instance? SomeClass input) 
  (seq (process-some-class-instance input)) 
  (map  crazy  (:children input 
  
  
  Thanks for help and time. 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: How to write this in idiomatic Clojure code?

2012-11-15 Thread Laurent PETIT
Am I right in guessing that your input is some kind of tree where Someclass
instances are leafs and non-leaf nodes are represented by maps having a
:children key?

Sent from a smartphone, please excuse the brevity/typos.

Le 15 nov. 2012 à 23:33, Hussein B. hubaghd...@gmail.com a écrit :

Hi,

Would you please help me to morph this to an idiomatic Clojure ?

(defn crazy [input]
(if (instance? SomeClass input)
(seq (process-some-class-instance input))
(map  crazy  (:children input


Thanks for help and time.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with
your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: How to write this in idiomatic Clojure code?

2012-11-15 Thread Hussein B.
Yes true.

If it is leaf , do process-some-class-instance

If it is not, then it could hold a collection of nodes and leafs (a mixture)

Actually , I'm checking tree-seq but I don't know how to use it in my case.

Any ideas ?

On Friday, November 16, 2012 1:06:22 AM UTC+2, lpetit wrote:

 Am I right in guessing that your input is some kind of tree where 
 Someclass instances are leafs and non-leaf nodes are represented by maps 
 having a :children key?

 Sent from a smartphone, please excuse the brevity/typos.

 Le 15 nov. 2012 à 23:33, Hussein B. hubag...@gmail.com javascript: 
 a écrit :

 Hi,

 Would you please help me to morph this to an idiomatic Clojure ?

 (defn crazy [input]
 (if (instance? SomeClass input)
 (seq (process-some-class-instance input))
 (map  crazy  (:children input


 Thanks for help and time.

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Proposed change to let- syntax

2012-11-15 Thread Alex Nixon
For reference, the current
implementationhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6753
.

On 15 November 2012 22:44, Andy Fingerhut andy.finger...@gmail.com wrote:

 Check git commit logs from a month or so ago.  Rich Hickey committed it.

 Andy

 Sent from my iPhone

 On Nov 15, 2012, at 2:41 PM, Mark Engelberg mark.engelb...@gmail.com
 wrote:

 Where did you find the proposal?  I can't find any info about let-

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
*Alex Nixon*

Software Engineer | SwiftKey

*a...@swiftkey.net** | http://www.swiftkey.net/*

++
WINNER - MOST INNOVATIVE MOBILE
APPhttp://www.swiftkey.net/swiftkey-wins-most-innovative-app-at-mwc
 - GSMA GLOBAL MOBILE AWARDS 2012

Head office: 91-95 Southwark Bridge Road, London, SE1 0AX TouchType is a
limited company registered in England and Wales, number 06671487.
Registered office: 91-95 Southwark Bridge Road, London, SE1 0AX

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: code waiting on something - cannot debug - driving me insane!!!

2012-11-15 Thread Jim - FooBar();

Wow! Unbelievable !

So there is nothing wrong with my code?
After reading this thread, it seems like a serious issue...the entire 
repl becomes  unusable which greatly limits the interactive experience.


But then,

what happens in Eclipse? the same principle applies? From my experience 
with Java I know that eclipse spawns a new VM every time you run a 
projectwhat's happening there? why does eclipse crash completely?


btw, thanks for spotting this :-) ...at least now i can stop fiddling 
with my code and start looking for a workaround towards the right 
direction. Hiding the frame temporarily, would allow me to at least work 
easier. I'll try tomorrow...


Jim



On 15/11/12 22:42, Karsten Schmidt wrote:

Hi Jim, isn't that just due to the fact that closing the Swing frame
kills the nrepl server JVM, but not the REPL client?

Also discussed here:
https://groups.google.com/forum/?fromgroups=#!topic/leiningen/QLcZIK2e5C0

I agree, it's annoying, but not sure how to workaround it? Maybe with
a heartbeat between nrepl client/server with the client closing the
repl session if the heartbeat been missing for x seconds...

Hth! K.


On 13 November 2012 23:25, Jim - FooBar(); jimpil1...@gmail.com wrote:

The original project is already on github...I just committed the dummy
namespace as well so you can have a look...
so, do:

git clone https://github.com/jimpil/Clondie24.git
cd Clondie24
lein2 repl

(load-file Clondie24.games.dummy.clj)
(ns Clondie24.games.dummy)
(-main)

then close the frame without doing anything and try evaluating anything (e.g
(:name details)).
it goes without saying that the same thing happens in all other proper games
as well...

thanks a million for looking into this :-)

Jim



On 13/11/12 22:35, Laurent PETIT wrote:

Could you create a small lein2 project on github with what you
previously pasted in this thread correctly spread over files, etc., so
that it's really quick to reproduce the error?

Thanks,

Laurent

Sent from a smartphone, please excuse the brevity/typos.

Le 13 nov. 2012 ą 22:52, Jim - FooBar(); jimpil1...@gmail.com a écrit
:


On 13/11/12 21:45, Dave Ray wrote:

Dump the JVM's threads [1] and see what it's stuck on?

What am I looking for? I don't see anything related with my project...IT
is pretty obvious from the output though that everything is waiting! No clue
what though...

Jim

-

2012-11-13 21:47:16
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.2-b09 mixed mode):

Thread-11 prio=10 tid=0x7f4268022800 nid=0x1fc8 waiting on
condition [0x7f4258338000]
java.lang.Thread.State: TIMED_WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  0xc286d270 (a
java.util.concurrent.SynchronousQueue$TransferStack)
 at
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
 at
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
 at
java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
 at
java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
 at
clojure.tools.nrepl.transport$fn_transport$fn__1008.invoke(transport.clj:41)
 at clojure.tools.nrepl.transport.FnTransport.recv(transport.clj:28)
 at reply.eval_modes.nrepl$main$fn__1451.invoke(nrepl.clj:154)
 at clojure.lang.AFn.run(AFn.java:24)
 at java.lang.Thread.run(Thread.java:722)

NonBlockingInputStreamThread daemon prio=10 tid=0x7f42685d9000
nid=0x1fc5 in Object.wait() [0x7f4258439000]
java.lang.Thread.State: WAITING (on object monitor)
 at java.lang.Object.wait(Native Method)
 - waiting on 0xc286b100 (a
jline.internal.NonBlockingInputStream)
 at
jline.internal.NonBlockingInputStream.run(NonBlockingInputStream.java:278)
 - locked 0xc286b100 (a
jline.internal.NonBlockingInputStream)
 at java.lang.Thread.run(Thread.java:722)

process reaper daemon prio=10 tid=0x7f42685d5000 nid=0x1fbf waiting
on condition [0x7f4258461000]
java.lang.Thread.State: TIMED_WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  0xc286d7e8 (a
java.util.concurrent.SynchronousQueue$TransferStack)
 at
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
 at
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
 at
java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
 at
java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
 at
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
 at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
 at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
 at 

Re: Proposed change to let- syntax

2012-11-15 Thread Mark Engelberg
Thanks Alex.

My two cents is that your syntax is more the way I'd expect it to look,
starting off like an actual let with support for destructuring, followed by
the forms.

Only advantage I can think of for the one in core is that it enforces that
you only have one binding.  Basing let- off of let notation might cause
people to think you could bind multiple vars to values in the initial
bracketed part; that would be somewhat nonsensical.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: code waiting on something - cannot debug - driving me insane!!!

2012-11-15 Thread Jim - FooBar();
Oops! I can use :dispose instead of :exit. If it does what it implies, 
it should do the job...


Jim

On 15/11/12 23:29, Jim - FooBar(); wrote:

Wow! Unbelievable !

So there is nothing wrong with my code?
After reading this thread, it seems like a serious issue...the entire 
repl becomes  unusable which greatly limits the interactive experience.


But then,

what happens in Eclipse? the same principle applies? From my 
experience with Java I know that eclipse spawns a new VM every time 
you run a projectwhat's happening there? why does eclipse crash 
completely?


btw, thanks for spotting this :-) ...at least now i can stop fiddling 
with my code and start looking for a workaround towards the right 
direction. Hiding the frame temporarily, would allow me to at least 
work easier. I'll try tomorrow...


Jim



On 15/11/12 22:42, Karsten Schmidt wrote:

Hi Jim, isn't that just due to the fact that closing the Swing frame
kills the nrepl server JVM, but not the REPL client?

Also discussed here:
https://groups.google.com/forum/?fromgroups=#!topic/leiningen/QLcZIK2e5C0 



I agree, it's annoying, but not sure how to workaround it? Maybe with
a heartbeat between nrepl client/server with the client closing the
repl session if the heartbeat been missing for x seconds...

Hth! K.


On 13 November 2012 23:25, Jim - FooBar(); jimpil1...@gmail.com wrote:

The original project is already on github...I just committed the dummy
namespace as well so you can have a look...
so, do:

git clone https://github.com/jimpil/Clondie24.git
cd Clondie24
lein2 repl

(load-file Clondie24.games.dummy.clj)
(ns Clondie24.games.dummy)
(-main)

then close the frame without doing anything and try evaluating 
anything (e.g

(:name details)).
it goes without saying that the same thing happens in all other 
proper games

as well...

thanks a million for looking into this :-)

Jim



On 13/11/12 22:35, Laurent PETIT wrote:

Could you create a small lein2 project on github with what you
previously pasted in this thread correctly spread over files, etc., so
that it's really quick to reproduce the error?

Thanks,

Laurent

Sent from a smartphone, please excuse the brevity/typos.

Le 13 nov. 2012 ą 22:52, Jim - FooBar(); jimpil1...@gmail.com a 
écrit

:


On 13/11/12 21:45, Dave Ray wrote:

Dump the JVM's threads [1] and see what it's stuck on?
What am I looking for? I don't see anything related with my 
project...IT
is pretty obvious from the output though that everything is 
waiting! No clue

what though...

Jim

- 



2012-11-13 21:47:16
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.2-b09 mixed 
mode):


Thread-11 prio=10 tid=0x7f4268022800 nid=0x1fc8 waiting on
condition [0x7f4258338000]
java.lang.Thread.State: TIMED_WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  0xc286d270 (a
java.util.concurrent.SynchronousQueue$TransferStack)
 at
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226) 


 at
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460) 


 at
java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359) 


 at
java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
 at
clojure.tools.nrepl.transport$fn_transport$fn__1008.invoke(transport.clj:41) 

 at 
clojure.tools.nrepl.transport.FnTransport.recv(transport.clj:28)

 at reply.eval_modes.nrepl$main$fn__1451.invoke(nrepl.clj:154)
 at clojure.lang.AFn.run(AFn.java:24)
 at java.lang.Thread.run(Thread.java:722)

NonBlockingInputStreamThread daemon prio=10 tid=0x7f42685d9000
nid=0x1fc5 in Object.wait() [0x7f4258439000]
java.lang.Thread.State: WAITING (on object monitor)
 at java.lang.Object.wait(Native Method)
 - waiting on 0xc286b100 (a
jline.internal.NonBlockingInputStream)
 at
jline.internal.NonBlockingInputStream.run(NonBlockingInputStream.java:278) 


 - locked 0xc286b100 (a
jline.internal.NonBlockingInputStream)
 at java.lang.Thread.run(Thread.java:722)

process reaper daemon prio=10 tid=0x7f42685d5000 nid=0x1fbf 
waiting

on condition [0x7f4258461000]
java.lang.Thread.State: TIMED_WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  0xc286d7e8 (a
java.util.concurrent.SynchronousQueue$TransferStack)
 at
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226) 


 at
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460) 


 at
java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359) 


 at
java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
 at
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043) 



Re: Proposed change to let- syntax

2012-11-15 Thread Alex Nixon
Thanks for the comments.

Regarding the bindings, I'd point out that if-let and when-let already work
this way (enforcing one binding) and so it isn't introducing any
inconsistency.

On 15 November 2012 23:34, Mark Engelberg mark.engelb...@gmail.com wrote:

 Thanks Alex.

 My two cents is that your syntax is more the way I'd expect it to look,
 starting off like an actual let with support for destructuring, followed by
 the forms.

 Only advantage I can think of for the one in core is that it enforces that
 you only have one binding.  Basing let- off of let notation might cause
 people to think you could bind multiple vars to values in the initial
 bracketed part; that would be somewhat nonsensical.

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
*Alex Nixon*

Software Engineer | SwiftKey

*a...@swiftkey.net** | http://www.swiftkey.net/*

++
WINNER - MOST INNOVATIVE MOBILE
APPhttp://www.swiftkey.net/swiftkey-wins-most-innovative-app-at-mwc
 - GSMA GLOBAL MOBILE AWARDS 2012

Head office: 91-95 Southwark Bridge Road, London, SE1 0AX TouchType is a
limited company registered in England and Wales, number 06671487.
Registered office: 91-95 Southwark Bridge Road, London, SE1 0AX

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Difference between JVM and CLR when destructuring a lazy sequence

2012-11-15 Thread dmiller
The difference is that the JVM version is correct and the CLR 
implementation has a bug.

I'll fix it in the current branch and try to get a patched 1.4 out as soon 
as I can.

-- Above is all you really need to know, but I find myself forced to 
continue. :) --

This bug has sitting there from the first commit in the public repo. (That 
would be early 2009.)  The line of code in question is testing for the 
IList interface.  The line has a comment that the JVM implementation 
changed from IList to RandomAccess, which has no equivalent in the CLR.  I 
didn't know why the change was made, so I left it alone.  (The history is 
lost, but I can place the JVM version change between Nov 08 and Feb 09.) 
Four years later, I've just discovered the reason.  The bug only surfaces 
in certain circumstances on infinite (lazy) sequences -- and specifically 
it is triggered by destructuring.  LazySeq itself is not the problem -- 
that's used everywhere.

-David



On Thursday, November 15, 2012 9:23:05 AM UTC-6, ffailla wrote:

 I believe I have discovered differing behavior between the JVM and CLR 
 implementations when running the following statement:

 user (let [foo (repeatedly (fn [] (let [r (rand)]
 (println in-repeat:  r)
 r)))
  [f  rst] foo]
  (println return:  f))

 When run on the JVM with clojure 1.4.0, I get the following output:

 in-repeat:  0.6929552277817549
 in-repeat:  0.7005322422752974
 return:  0.6929552277817549
 nil
 user 

 When run on the CLR with clojure-clr 1.4.0, the random number will be 
 printed from in-repeat infinitely, never to return.

 Is this difference between the JVM and CLR implementations when 
 destructuring a lazy sequence known?  

 Also, why was the random number printed twice on the JVM side.  I haven't 
 looked an the implementation, but I would guess this would be due to 
 chunking the sequence. Thanks.

 -Frank Failla 


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Proposed change to let- syntax

2012-11-15 Thread Alan Malloy
The primary point of let- is that you can insert it into an existing - 
pipeline. 

(- foo
(stuff)
(blah)
(let- foo-with-stuff
  (for [x foo-with-stuff]
(inc x)))

Your proposal breaks this.

On Thursday, November 15, 2012 10:35:59 AM UTC-8, Alex Nixon wrote:

 Hi all,

 I find the proposed function let- in Clojure 1.5 very useful, but a bit 
 ugly.  The arguments are backwards when compared to vanilla let, and it 
 doesn't support destructuring where it easily could (which I believe would 
 be helpful when threading 'state-like' maps, as I find let- very useful 
 for).

 I'd like to float an alternative implementation which improves on both 
 these issues.  Thoughts?

 (defmacro new-let-
   Establishes bindings as provided for let, evaluates the first form
in the lexical context of that binding, then re-establishes bindings
to that result, repeating for each successive form
   [bindings  forms]
   (assert (vector? bindings) binding must be a vector)
   (assert (= 2 (count bindings)) binding vector must contain exactly two 
 forms)
   `(let [~@bindings
  ~@(interleave (repeat (bindings 0)) (drop-last forms))]
  ~(last forms)))

 (new-let- [{:keys [foo bar] :as state} {:foo 1 :bar 2}] 
   (assoc state :foo (inc bar))
   (assoc state :bar (inc foo))) ; = {:foo 3, :bar 4}

 -- 
 *Alex Nixon*

 Software Engineer | SwiftKey

 *al...@swiftkey.net javascript:** | http://www.swiftkey.net/*

 ++
 WINNER - MOST INNOVATIVE MOBILE 
 APPhttp://www.swiftkey.net/swiftkey-wins-most-innovative-app-at-mwc
  - GSMA GLOBAL MOBILE AWARDS 2012

 Head office: 91-95 Southwark Bridge Road, London, SE1 0AX TouchType is a 
 limited company registered in England and Wales, number 06671487. 
 Registered office: 91-95 Southwark Bridge Road, London, SE1 0AX

  

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Proposed change to let- syntax

2012-11-15 Thread Mark Engelberg
On Thu, Nov 15, 2012 at 5:17 PM, Alan Malloy a...@malloys.org wrote:

 The primary point of let- is that you can insert it into an existing -
 pipeline.


That makes sense.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Nested/inner classes with gen-class

2012-11-15 Thread Jonathan Bryant
Googled and asked on the IRC channel, but I can't find a solution.  Maybe 
someone here can help :)

I'm trying to generate nested/inner classes with gen-class.  I can't just 
write the classes in Java because I'm generating them off of data 
structures declared in Clojure.  For context, I'm taking an Avro schema 
with arbitrarily nested records and building a Java API for working with 
objects to be (de-)serialized.  I can hack around the problem by generating 
a bunch of classes at the top level, but since the nested records aren't 
needed elsewhere, inner classes make the most sense.

Basically, I have this:

{:name foo.Bar
 :type record
 :fields [
{:name Baz
 :type record
 :fields [
   {:name quux
:type int}]}]}

and I want to walk it and generate a class that can be used as if it were 
written in Java as:

package foo;

public class Bar {
  class Baz {
private int quux;

public int getQuux() {
  return quux;
}

public void setQuux(int quux) {
  this.quux = quux;
}
  }

  private Baz baz;

  public Bar() {
this.baz = new Baz();
  }

  public Baz getBaz() {
return baz;
  }

  public void setBaz(Baz baz) {
this.baz = baz;
  }
}

I can do this except for the inner class bit (I would really like to load 
the class immediately, but gen-and-load-class seems to have disappeared 
leaving only gen-class :-/ )  I can generate foo.Bar and foo.BarBaz, but 
that seems awkward and unnecessary if I could generate the inner class.

This seems to compile in a file by itself:

(gen-class 'foo.Bar$Baz
  ; ... stuff ... )

But when another file references it:

(ns whatever
  (:import foo.Bar$Baz))

clojure asplodes, even when manually AOT compiling the files in order.

Any solution?

Thanks!

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

freeing resources while generating lazy sequences

2012-11-15 Thread Alex Pooley
Hey Folks,

I am writing a thin Clojure wrapper around 
leveldbjni https://github.com/fusesource/leveldbjni

Leveldbjni provides an iterator to walk over all key, value pairs in the 
database. I am trying to translate this iterator functionality in to a 
Clojure lazy sequence. I've built my function, but I hit a couple of issues 
in the process that I would like to float by the wise Clojure sages on this 
list...

1. I seemed unable to use iterator-seq on the iterator. I assumed this was 
because leveldbjni is faking an iterator interface due to cpp/jni 
interop. Can anyone confirm this?
2. I need to close the iterator to free the resource. This seems to make it 
difficult to build an efficient lazy sequence? One option is to open, 
seek, close to generate the next pair in the sequence but I'm pretty sure 
this would turn an O(N) iteration in to an O(N^2) iteration. Also, the DB 
will get large so I'd rather not slurp everything in to memory. Maybe I 
could slurp in chunks? Is anyone able to add/improve/comment on this?

At risk of diverting the focus of this post to my mediocre Clojure code, 
here's my function to date for completeness sake. Please note that I am a 
Clojure noob :)


(defn pairs
  Lazy sequence of key, value pairs in the database
  ([db]
(let [iter (.iterator db)]
  (.seekToFirst iter)
  (pairs db iter)))
  ([db iter]
(lazy-seq
  (if (.hasNext iter)
(let [pair (.peekNext iter)
  pair-key (JniDBFactory/asString (.getKey pair))
  pair-value (JniDBFactory/asString (.getValue pair))
  _ (.next iter)]
  (cons [pair-key pair-value] (pairs db iter)))
nil


All help greatly appreciated.

Many thanks,

Alex.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: How to write this in idiomatic Clojure code?

2012-11-15 Thread Laurent PETIT
(map #(seq (process-some-class-instance %))
   (tree-seq map? :children input))

Sent from a smartphone, please excuse the brevity/typos.

Le 16 nov. 2012 à 00:13, Hussein B. hubaghd...@gmail.com a écrit :

Yes true.

If it is leaf , do process-some-class-instance

If it is not, then it could hold a collection of nodes and leafs (a mixture)

Actually , I'm checking tree-seq but I don't know how to use it in my case.

Any ideas ?

On Friday, November 16, 2012 1:06:22 AM UTC+2, lpetit wrote:

 Am I right in guessing that your input is some kind of tree where
 Someclass instances are leafs and non-leaf nodes are represented by maps
 having a :children key?

 Sent from a smartphone, please excuse the brevity/typos.

 Le 15 nov. 2012 à 23:33, Hussein B. hubag...@gmail.com javascript:
 a écrit :

 Hi,

 Would you please help me to morph this to an idiomatic Clojure ?

 (defn crazy [input]
 (if (instance? SomeClass input)
 (seq (process-some-class-instance input))
 (map  crazy  (:children input


 Thanks for help and time.

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com javascript:
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

  --
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with
your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

How to add the comment of a function into the compiled java class

2012-11-15 Thread Goldritter
Hi,

I try add Clojure into a Java project.
Therefore I write my code in Clojure and then compile the clj-File to Java 
classes and use these compiled classes in my Javacode.
My problem is, that the commentary I wrote for the clojure function is not 
shown in the compiled java class or the method defined in 'gen-class'. 

Is it possible to generate a Javadoc from clojure files or is there a 
parameter available for :gen-class which generates the javadoc which can be 
displayed my my IDE?

(As IDE I use Eclipse with the Counterclockwise Plugin.)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: [lein-cljsbuild] exclude a cljs from compilation

2012-11-15 Thread Evan Mezeske
Hi Mimmo,

Unfortunately, there's no way to do that right now.  I can't even think of 
a decent workaround (although that doesn't mean there isn't one).

This is part of a more general problem, which is that each build can only 
have a single :source-path and is not otherwise customizable.  If you could 
specify a vector of :source-paths, you could solve this problem pretty 
easily.  And once there was support for that, things like :exclude would be 
easy to implement.

If you wouldn't mind, please create a new issue, or maybe just add to this 
one: https://github.com/emezeske/lein-cljsbuild/issues/108 .

Thanks,
-Evan

On Thursday, November 15, 2012 6:56:45 AM UTC-7, Mimmo Cosenza wrote:

 Hi all, 
 my question is the following: 

 - I like to have the usual brepl connect to the browser during development 
 - I like to have the same source-base (e.g. :source-path src/cljs) for 
 both the development and production builds (e.g. :builds {:prod {.} 
 {:dev {.} of :cljsbuild keyword) 

 Is there a way in lein-cljsbuild to reach this goal? I'd like to write 
 something like this in :prod build 

 (defproject 

   :cljsbuild {:builds 
   {:dev {:source-path src/cljs 
  :compiler :output-to 
 resources/public/js/main_debug.js 
:optimizations :whitespace 
:pretty-print true}} 
 :prod {:source-path src/cljs 
 ;;; here a key/values to exclude some file in 
 :source-path from compilation, something like :exclude [afil.cljs 
 another-file.cljs] 
 :compiler :output-to 
 resources/public/js/main.js 
:optimizations :advanced}}) 


 Thanks for the attention 

 Mimmo 



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en