Re: Default values

2015-02-21 Thread Ulises
What's happening is that you have multiple optional arguments chained together. Optional arguments are passed as a list (or seq?) of arguments, so if you pass them down to another function that also takes optional arguments they get wrapped in yet another list. An option to stop this is to use

Re: How to refactor data safely?

2014-05-22 Thread Ulises
How are you accessing the data? I suppose that if you were accessing (maybe you are) the data via helper functions, that's where most of the refactoring should happen. On 22 May 2014 09:17, Jakub Holy jakub.h...@iterate.no wrote: I have a nested data structure, used by a bunch of functions

Re: Clojure Office Hours

2014-04-28 Thread Ulises
Thanks for the pointer Jakob. I've updated the form accordingly. Cheers, On 28 April 2014 10:56, Jakub Holy jakub.h...@iterate.no wrote: I too have booked a session with Ulises and am excited about it :-) @Ulises It would be nice if the timezone of the session was mentioned on the booking

Re: Clojure Office Hours

2014-04-25 Thread Ulises
And if you are in Europe, remember that Ulises is still offering, at what looks like 1300-1400 UTC (I think): https://ucb.youcanbook.me/https://www.google.com/url?q=https%3A%2F%2Fucb.youcanbook.me%2Fsa=Dsntz=1usg=AFQjCNGoo6exDmYGhdu-4qu3L9tL2v8AkQ It's actually 9-10am BST, but thanks

Re: Clojure Office Hours

2014-04-18 Thread Ulises
Inspired by Leif's offer, I've decided to offer Clojure office hours as well. I'm based in the UK so I reckon the times will be more amenable to those in Europe (not sure the times will be good for those in Asia unfortunately.) Sadly the offer is limited to 1h a day, but hopefully it'll still be

Re: Clojure Office Hours

2014-04-18 Thread Ulises
sharing, as well as Google hangouts. Once you've booked an appointment with me please email me privately to arrange the pairing set up so that I can be ready for you :) Cheers On 18 April 2014 10:35, Ulises ulises.cerv...@gmail.com wrote: Inspired by Leif's offer, I've decided to offer Clojure

Re: How did you learn Clojure?

2014-03-21 Thread Ulises
When I started learning clojure back in 2010 I decided to give a presentation about it at work. That set a deadline (about 3 months) in which I had to learn the language. Having said that, I learnt /the language/ however wroting code (toy or not) reading other people's code, getting code reviews

Re: [ANN] Buffy The ByteBuffer Slayer, Clojure library to working with binary data

2013-12-04 Thread Ulises
While we're on the subject, I found no way of decoding/interpreting an already existing sequence (ByteBuffer) of bytes, but only one that had been created with compose-buff. Am I missing something? On 4 December 2013 07:28, Cesar Canassa cesar.cana...@gmail.com wrote: Hi, I see that the

Re: ANN: Clojure High Performance Programming

2013-11-21 Thread Ulises
Thank you! The book is published very recently and I noticed it took a while for the printed editions to appear on Amazon. I am getting in touch with Packt to find out why the kindle editions not on Amazon and whether this is temporary. Great! Thanks for the diligence. If you're getting in

Re: ANN: Clojure High Performance Programming

2013-11-21 Thread Ulises
Could you please let me know which URL and page no. did you find the images missing on? I noticed the images are visible (for example on page number 21) when I visited http://www.amazon.com/dp/1782165606/?tag=packtpubli-20 and clicked on the book image to open the preview. Apologies for the

Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Ulises
If you're not planning on changing the value of your defined index, you can always use partial, e.g.: (def search (partial es/search es-index)) On 9 September 2013 09:42, Mark Mandel mark.man...@gmail.com wrote: Hey all, Relatively new to Clojure, and I'm wondering if there is a

Re: ANN Introducing EEP, a young [event] stream processing library

2013-09-06 Thread Ulises
I'm sure it's a bit early but is there a mailing list for this? I've ran into trouble trying EEP on a really simple flow (the even vs. odds in the docs.) and I'd like to ask a few questions. U On 6 September 2013 02:24, Timothy Pratley timothyprat...@gmail.com wrote: Awesome! Thank you for

Re: Structing Clojure tests/setup and tear down

2013-05-21 Thread Ulises
Perhaps you're looking for fixtures? http://thornydev.blogspot.co.uk/2012/09/before-and-after-logic-in-clojuretest.html U On 21 May 2013 15:17, Colin Yates colin.ya...@gmail.com wrote: Howdy, I am using clojure.test and have some questions of how to write idiomatic Clojure. This really

Re: Structing Clojure tests/setup and tear down

2013-05-21 Thread Ulises
Hey Colin, Apologies, I missed your First - I know about fixtures... line :) I'd probably +1 Gaz's macro (I've not tested it either but it looks reasonable.) On 21 May 2013 16:05, Colin Yates colin.ya...@gmail.com wrote: Hi Ulises, I don't think I am as that would require essentially

Re: unusual question: how do you get morale?(or moral support)

2013-05-13 Thread Ulises
Code that matters is code that's used by other people. For me personally the ability to share my code with others is the thing that makes programming worth doing in the first place. This is a rather important point. One of the most asked questions (random made up fact) by newcomers to a

Re: emacs - how to wean me off the family of Java IDEs

2013-05-01 Thread Ulises
The biggest 'ah - got it' for me was when I realised IDEs are great for navigating huge object models which are relatively narrow but deep (i.e. lots of nested relationships). This requires a special set of navigation skills (cntrl-click to go to declaration, autocompletion etc). Clojure

Re: emacs - how to wean me off the family of Java IDEs

2013-05-01 Thread Ulises
? On 1 May 2013 12:13, Ulises ulises.cerv...@gmail.com wrote: The biggest 'ah - got it' for me was when I realised IDEs are great for navigating huge object models which are relatively narrow but deep (i.e. lots of nested relationships). This requires a special set of navigation skills

Re: Parallelizing tasks

2013-04-10 Thread Ulises
Have you tried replacing all your calls to map for pmap yet? On 11 April 2013 03:33, Bruno Kim Medeiros Cesar brunokim...@gmail.comwrote: Hello. I am replicating the study made by John D. Cook in thishttp://www.johndcook.com/blog/2013/02/25/exact-chaos/post about exact chaos in Clojure,

Re: Opinion on testing strategies?

2013-04-07 Thread Ulises
Forgive me if I completely misunderstood your question. Replies inline. One way is to use `with-redefs`. This technique would be used at every level along the pyramid (except the bottom level which doesn't call anything else). This would be similar to mocking, correct? If so, what'd be wrong

Re: Faster lein

2013-02-20 Thread Ulises
I've been using drip with quite some success (with the exception of midje tests which seem to launch their own jvm every time.) On 20 February 2013 15:53, Buck Golemon workithar...@gmail.com wrote: I see that lein2 has factored out the 'interactive' command. Can I use lein1 and expect the

Re: Help on implementing a simple java (openNLP) EventStream interface

2013-02-14 Thread Ulises
How about having your methods access an atom provided in a closure like it's done here: http://kotka.de/blog/2010/03/proxy_gen-class_little_brother.html U On 14 February 2013 13:58, Joachim De Beule joachim.de.be...@gmail.comwrote: Hi All, I want to turn a clojure sequence into an

Re: Help on implementing a simple java (openNLP) EventStream interface

2013-02-14 Thread Ulises
-stream [input-seq] (let [remaining (atom input-seq)] (proxy [EventStream] [] (next [] (let [current (first @remaining)] (swap! remaining rest) (elt-event current))) (hasNext [] (not (empty? @remaining)) 2013/2/14 Ulises

Re: Article on Clojure concurrency from Computing in Science and Engineering

2013-02-08 Thread Ulises
+1 on pdf On 8 February 2013 10:30, Konrad Hinsen googlegro...@khinsen.fastmail.netwrote: The article Clojure for Number Crunching on Multicore Machines by Martin Kalin and David Miller Computing in Science and Engineering Nov/Dec 2012 is in free access at the moment:

Re: Consuming web services in Clojure

2012-11-05 Thread Ulises
Try clj-http (https://github.com/dakrone/clj-http) On 5 November 2012 12:12, N8Dawgrr nathan.r.matth...@gmail.com wrote: Hi All, Does anyone know of a good simple library to call/consume web-services from Clojure? Note I don't want to create a web-service just call one. -- You

Re: Midje popularity?

2012-10-17 Thread Ulises
Does anyone use Midje currently? I most definitely do! And thanks for porting midje-mode to nrepl. I've recently been migrating to nrepl and friends and I was missing my midje-mode! U -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Fizz-Buzz and Church Numerals

2012-09-14 Thread Ulises
Hi, I've translated the code in http://experthuman.com/programming-with-nothing to Clojure and here's the result: - https://www.refheap.com/paste/5073/fullscreen (code) - https://www.refheap.com/paste/5074/fullscreen (tests) Cheers, Ulises -- You received this message because you

Re: redefining multimethods at the repl

2012-09-04 Thread Ulises
Binding to the var instead of the value will allow it to be udpated. Alternatively you could ns-unmap the multimethod before redefining it. U -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: (merge) = nil

2012-08-29 Thread Ulises
Don't know why nil is returned instead of {}, but (+) = 0 (*) = 1 following that line of reasoning: (merge nil {:a 1}) {:a 1} (merge {} {:a 1}) {:a 1} -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: real-world usage of reducers?

2012-08-22 Thread Ulises
Apologies in advance if this is a silly question but have you tried profiling your code to see where the hotspots are? U -- 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

Re:

2012-07-29 Thread Ulises
Here's an edge case for you: (has22 [1 2 2 1]) ; false :) U -- 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

Re: atom and lock

2012-07-18 Thread Ulises
Please excuse my ignorance and my late comment, but can you make your 1hr operation shorter? The general advice I've always been given has been whenever you need to use a resource that might cause contention do it quickly, in and out in a blink. I know that the argument then would be why do I

Re: General subsequence function

2012-06-27 Thread Ulises
I'd forgotten that 'into adds things in the default place for whatever type you're using, hence the reversal on lists. I'm not sure if there's a simple way to get the same type out again while preserving order. How about: (defn sub-seq [start end coll] (take (- end start) (drop start

Re: Explaining the thrush - operator.

2012-06-10 Thread Ulises
Additional to all the positive comments, I'd suggest you use an operator which is not commutative, otherwise the differences between - and - are less evident. U -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Network Visual Layout Algorithm

2012-05-31 Thread Ulises
I have a contest going with a colleague, where we each have to render a network layout in SVG.  My gut says that Synthetic Annealing is the right tool for the job here. I haven't heard of synthetic annealing (I have heard of simulated annealing though) but if you're looking to draw a network

Re: [ANN] clojure-echonest-api

2012-05-25 Thread Ulises
I am unsure about the atom of api-key, in theory i won't need to change my api-key, but idk... You can get a lot of api-key gratis which are a little limited or just one payed api-key that can do everything... My point was that once you've declared api-key {:dynamic true} (which by the way is

Re: [ANN] clojure-echonest-api

2012-05-23 Thread Ulises
Looking the code again I believe that I should use a future and not an agent... I am right ??? I would think so. AFAIK, the advice has always been if you need to do some computation on another thread don't (ab)use agents, use futures. Additionally, you have[1]: (def #^{:dynamic true}

Re: cld 0.1.0 - Clojure Language Detection

2012-03-01 Thread Ulises
Apologies for hijacking this thread, but this is probably the most relevant place to point you to a simple web-frontend to cld I cooked up in a couple of hours: http://detector-de-idioma.herokuapp.com/index.html Additionally, you can call it as a service like $ url

Re: cld 0.1.0 - Clojure Language Detection

2012-02-29 Thread Ulises
I'm more curious about why the output isn't even deterministic. The same input string produced three different results. You can see in the FAQ (http://code.google.com/p/language-detection/wiki/FrequentlyAskedQuestion) that: Langdetect uses random sampling for avoiding local noises(person name,

Re: Literate programming in emacs - any experience?

2012-01-28 Thread Ulises
Here's a paper that might be interesting to folk discussing in this thread: http://www.jstatsoft.org/v46/i03/paper Cheers U -- 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

Re: Clojure Extension for Chrome

2012-01-08 Thread Ulises
Interesting plugin. I've been pondering for a while about whether it'd be interesting to write clojure (or language X) blog posts in a literate fashion, i.e. with weave and tangle that knew how to download the post and then extract and execute the code. This would come in rather handy since more

Re: Trying to use CDT on 1.3.0

2011-12-10 Thread Ulises
Alternatively you can just do: $ lein plugin install swank-clojure 1.3.3 and have swank across projects without having to add your :dev-dependencies for each one. U -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Get multiple vals from a map

2011-12-01 Thread Ulises
How about using juxt: sandbox ((juxt :foo :bar) {:foo 1 :bar 2 :baz 0}) [1 2] sandbox This only works, however, if you use keywords for keys (as they are functions themselves). U -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,

Re: Forcing computation

2011-11-15 Thread Ulises
I understand that lazy sequences are very useful but sometimes, I want to compute everything, go away, and have it there when I come back. How do I do that with a map? (def x (map fn coll)) you could do (last x) and drop that value. U -- You received this message because you are subscribed

Re: Getting index of char from end

2011-11-12 Thread Ulises
Here's my take on it (all caveats apply, e.g. performance): (defn indices-of Returns the indices of the given char in the string (0 based). [c string] (map second (filter #(= c (first %)) (partition 2 (interleave string (iterate inc 0)) (indices-of \a abba) ; (0 3) and hence

Re: Open source Clojure projects

2011-11-09 Thread Ulises
Whenever I see a question like this asked anywhere (and even when I ask the question to myself or others) I usually recommend reading (or read myself): http://prog21.dadgum.com/80.html :) U -- You received this message because you are subscribed to the Google Groups Clojure group. To post to

Re: clojure starter package for aichallenge ?

2011-10-25 Thread Ulises
I failed to mention that both the files are in a directory named mybot I could be wrong but I think they have to be in the root of the zip file, i.e. no directories. I just zip up ants.clj and MyBot.clj into a file and it works. HTH, U -- You received this message because you are

Re: Nested identities in a value-based universe

2011-10-24 Thread Ulises
The problem with identities of actors comes in when you consider code like the following:  (def trantor (get-actor Trantor world-state))  (:hit-points trantor)  = 10  (def new-world-state ((command Trantor :eat apple) world-state))  (:hit-points trantor)  = 10     (still!! because we

Re: Nested identities in a value-based universe

2011-10-21 Thread Ulises
inside the universe and updating it, then you should be good to go. Cheers, Ulises -- 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

Re: partial, but instead of args + additional, get additional + args

2011-10-21 Thread Ulises
How about a potentially ugly workaround: user (defn sum [ {:keys [x y]} ] (+ x y)) #'user/sum user (sum :x 1 :y 2) 3 user (def inc-sum (partial sum :x 1)) #'user/inc-sum user (inc-sum :y 1) 2 user (inc-sum :y 2) 3 user I know this is a trivial example, but I do quite fancy named arguments and

Re: Nested identities in a value-based universe

2011-10-21 Thread Ulises
Are you arguing for my option b) then? In which case actors don't have distinct identities, they are just part of the overall world? Not necessarily as your option b) already gives implementation details (using ids to find actors, etc.). I was mostly thinking out loud to see if anything

Re: Nested identities in a value-based universe

2011-10-21 Thread Ulises
Maybe the world's state is that player Trantor is at position [15 34]. Now Trantor eats an appel. The appel is removed from his inventory and his health is raised by 5 hit points. Did the state of the world change? No. Trantor is still at position [15 34]. Does the world have to know about the

Re: How to flatten a nested sequence?

2011-10-04 Thread Ulises
your subject contains the answer :) sandbox (def s1 (seq [s1 (seq [s2 s3]) s4 s5 (seq [s6 (seq [s7 s8]) s9])])) #'sandbox/s1 sandbox s1 (s1 (s2 s3) s4 s5 (s6 (s7 s8) s9)) sandbox (flatten s1) (s1 s2 s3 s4 s5 s6 s7 s8 s9) sandbox (doc flatten) - clojure.core/flatten ([x])

Re: Wrapping an expression inside a function

2011-09-16 Thread Ulises
Not the right answer. I tried to use the apply function with no success. How can I wrap the expression inside a function. Why not use partition and interleave? user (partition 2 (interleave [:a :b] [:c :d])) ((:a :c) (:b :d)) U -- You received this message because you are subscribed to the

Re: is there some gotchas with the contains? function and strings?

2011-08-24 Thread Ulises
I believe contains? tests for the presence of a key in a collection: user (contains? {:a 1 :b 2} 1) false user (contains? {:a 1 :b 2} :a) true user (get [0 2 3] 1) 2 user (contains? [0 2 3] 1) true user From the docstring: Returns true if key is present in the given collection, otherwise

Re: How to Return Vector of Vectors

2011-07-22 Thread Ulises
An alternative is to use partition together with interleave: user (partition 2 (interleave [ 1 2 ] [ \a \b ])) ((1 \a) (2 \b)) Combined with (map vec ...) you should get: user (map vec (partition 2 (interleave [ 1 2 ] [ \a \b ]))) ([1 \a] [2 \b]) user U -- You received this message because

Re: Constructing clj-http Get Query

2011-07-20 Thread Ulises
try passing a map such as {:query-params {CA ca, street street ...}}. On 20 July 2011 16:24, Mark Rathwell mark.rathw...@gmail.com wrote: (require '[clj-http.client :as client]) (defn make-url [ca street-1 street-2 city state zip]   (let [url 

Re: Lazily read XML larger than memory: my take at parser API

2011-05-31 Thread Ulises
jackson can read/parse large JSON files through its streaming API: http://wiki.fasterxml.com/JacksonInFiveMinutes#Streaming_API_Example U -- 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

Re: find first non nil element of sequence

2011-05-27 Thread Ulises
You could use identity as a predicate to filter: user= (def s [nil nil 1 2 3]) #'user/s user= (first (filter identity s)) 1 user= U -- 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

Re: find first non nil element of sequence

2011-05-27 Thread Ulises
false is not nil. Ugh! Well spotted :) U -- 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

Re: RIncater

2011-05-23 Thread Ulises
Ugh! Actually, I was more after a wrapper around the Rserve client more than anything however RIncanter is the closest thing I could find.        Sortof.  The original author is updating thing so that they work more cleanly.  In the interim if you want to get it to work modify the project.clj

Re: Google Refine

2011-05-20 Thread Ulises
It's a way older older version of clojure but it's in there.  I've played around with it. You can always replace the jars (and include others such as support for Jython) and even add contrib. I've done that and it works just fine :) The one grief I had with GRefine is that once you create a

RIncater

2011-05-20 Thread Ulises
Hi, Is RIncanter still alive? Cheers, U -- 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

Re: What is the purpose of the Identity function?

2011-05-07 Thread Ulises
I usually use identity as a predicate for functions such as filter, drop-while, take-while, etc. Consider this silly example: imagine you had an operation that fetches stuff from a resource (DB, network, etc.) and that upon failing it returns nil. Additionally, imagine that you're interested in

Re: Getting the all the key values from hashmaps inside a vector

2011-04-20 Thread Ulises
If your keys were keywords, e.g. :key1, you could simply map them as they are also functions: (map :key1 ({:key1 value1} ...) U -- 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

Re: ANN: Clojure Atlas (preview!)

2011-04-19 Thread Ulises
I just clicked on Try it and only got to a short blurb and a subscribe form. Is this the right behaviour? U -- 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

Re: Open Source Projects for Beg/ Intermediate

2011-04-17 Thread Ulises
So, questions to Carin, Alex and Alan (and Ulises): What interests you? What problems do you have that you'd like solutions for? Knowing that, folks might be able to point you at existing projects to take part in (or might confirm no such project exists and they'd be interested

Re: Open Source Projects for Beg/ Intermediate

2011-04-16 Thread Ulises
Not long ago I was faced with the same dilemma: I am learning clojure and to practise and improve my skills I'd like to contribute to an open source project. Which one should I pick? And then I came across this: http://prog21.dadgum.com/80.html Enjoy :) U -- You received this message because

Re: Open Source Projects for Beg/ Intermediate

2011-04-16 Thread Ulises
I disapprove of discouraging people from offering to help with OSS: that's how you get started and how you get good. Well, it's not really discouraging. Or at least, I don't see it that way. I see it more like encouraging to contribute but not regardless of personal interest. Personal interest

Re: Adding key values in a list of maps

2011-04-15 Thread Ulises
user= (- p (map :b) (reduce +)) Alternatively: user (def p '({:a 1 :b 2 :c 4}, {:a 2 :b 3 :c 5}, {:a 3 :b 4 :c 6})) #'user/p user (:b (apply merge-with + p)) 9 Depending on whether you'll want the other sums or not, this approach might be appropriate. U -- You received this message because

Re: Clojure Interop With Java Using Eclipse.

2011-03-31 Thread Ulises
This has worked for me. Modify depending on your case. CAVEAT: I built a fatjar using $ lein uberjar which I then added as an external dependency in Eclipse. This included the clojure jar, the contrib and potentially lots of other stuff I had in my project. It is not entirely clear to me if one

Re: gen-class and state...

2011-03-24 Thread Ulises
Sorry for hijacking but I wouldn't mind some clarification on the subject. Right now I can get java classes and interfaces with defprotocol and defrecord and the world is good. Can somebody please educate me in the uses/needs for :gen-class and friends? Keep in mind that I haven't really done

Re: gen-class and state...

2011-03-24 Thread Ulises
You need gen-class when you want (or have to) derive from another class. defrecord/deftype/reify don't allow that, while gen-class/proxy do. I suppose this is for when you want to add fields to an already existing class? (I'm assuming that adding methods could be done with

Re: Monad Lessons

2011-03-10 Thread Ulises
I'd love to assit too (I like the fact that it'd be interactive). Just to let you know I'm on GMT (for when you schedule things). Cheers, U -- 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

simplistic M/R framework

2011-01-27 Thread Ulises
Hi, I've just implemented a simplistic map-reduce framework which mimics the steps involved in the workflow of a Hadoop job. It basically amounted to implementing a helper function to emit results and the shuffle-combine step which happens in between a map and a reduce task. Please consider that

simple map-reduce framework

2011-01-27 Thread Ulises
Hi, I've just implemented a simple map-reduce framework which mimics the steps involved in the workflow of a Hadoop job. It basically amounted to implementing a helper function to emit results and the shuffle-combine step which happens in between a map and a reduce task. Please consider that I am

Re: Moderately off-topic: installing emacs on OSX

2010-12-09 Thread Ulises
I would still like to see slime in action, however. I have two emacs installed, GNU and Aquamacs. macports is still not able to do anything Sorry if this sounds silly but have you tried with carbon emacs? I heard from old time hardcore emacsers that that is the best emacs for OS X (I'm not one

Re: priority queue for scheduling events in the future

2010-11-23 Thread Ulises
Does anybody know of an implementation for a priority queue that can be used for scheduling events in the future?  I would like to put a map associated with a timestamp into the queue and be able to pull out all maps at or before a given time in order. You can do so with a combination of

Re: println from within a thread

2010-11-20 Thread Ulises
This is how I'm running the test in the slime-connect buffer: How are you running the swank process? I usually run it as lein swank. Whenever I print inside a spawned thread I get the output in the console where I started swank. U -- You received this message because you are subscribed to the

Re: reducing terms in vector

2010-10-28 Thread Ulises
A little stuck on how to do this efficiently.  I have data that looks like this ( [ [1 2] [3 4] [5 6] ... ]  [ [5 6] [7 8] [9 0] ... ] ...) I am trying to sum the vector pairs, e.g [6 8] [10 12] [14 6] Try: user (def all-pairs '([ [1 2] [3 4] [5 6] ] [[5 6] [7 8] [9 0]]) )

Re: creating a function from a sexp

2010-10-27 Thread Ulises
Is it possible to write such a function? Perhaps you're looking for partial? user (def x 10) #'user/x user (let [y 5] (partial + x y)) #core$partial$fn__3680 clojure.core$partial$fn__3...@beebcd user ((let [y 5] (partial + x y)) 1) 16 user U -- You received this message because you are

Re: Improving Contrib

2010-10-22 Thread Ulises
I know this may be a silly question but: how does one get started helping with contrib/etc.? I'm only starting to learn clojure but I've found the community so helpful and thriving that I cannot help but to want to help ... what is the first step? U -- You received this message because you are

Re: Nested For(s)

2010-10-19 Thread Ulises
Alternatively you can do: user (def x 5) user (def y 7) user (take (* x y) (cycle (range x))) (0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4) user U -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

var vs. symbols

2010-10-11 Thread Ulises
Hi, I'm sure this has been asked before (although I couldn't find anything other than this StackOverflow thread http://stackoverflow.com/questions/2320348/symbols-in-clojure) and, in addition to that thread, I have a clarifying question: Am I right if I say that when I do (def foo 1) I'm

Re: var vs. symbols

2010-10-11 Thread Ulises
I guess one should use mapping instead of binding. The var is mapped to the symbol foo in the namespace *ns*. I'm saying that because functions for inspecting namespaces are (ns-map), Ah! Excellent, thanks. U -- You received this message because you are subscribed to the Google Groups

Re: var vs. symbols

2010-10-11 Thread Ulises
So I would say: Unqualified symbols in the namespace the def happened in will resolve to the def'd Var. (of course only after the def happened!) so in theory one could have a symbol foo bound to a var bar? U -- You received this message because you are subscribed to the Google Groups

Re: var vs. symbols

2010-10-11 Thread Ulises
Eh. No. I don't think so. The Var has a name and the symbol has a name. And an unqualified symbol is resolved to the closest Var with the same name (conveniently derefing the var to get its contents). This might be in the same namespace or in a different namespace which was :use'd. I'm still

Re: var vs. symbols

2010-10-11 Thread Ulises
Hope, that helps. It does indeed. So, def either creates or looks up a var of the name of the symbol given and then every time eval comes across a symbol it tries to lookup a var of the same name? (just read http://clojure.org/special_forms#def which I should've read before posting) Cheers

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Ulises
My take on this. I know it's convoluted, I know this is probably not the best and not even a good-enough solution, but it's what I have so far (needless to say, I'd welcome comments on my code :) (defn explode [ [k vals ] ] (map #(vector key %) vals)) (defn update-map [ m ] (partial apply assoc

Re: anonymous fn or partial?

2010-10-01 Thread Ulises
There is a subtle difference in how fixed arguments are handled. partial evaluates the arguments only once while fn evaluates them on each call. For side-effects free code the former can yield better performance. To recap: Ah! What a nice caveat! (also applies to taking macros as arguments).

anonymous fn or partial?

2010-09-30 Thread Ulises
Hi, Newbie here with a simple question: what is the preferred way of mapping a function to a seq? Use an anonymous function or use a partial? Consider this: user= (map (fn [n] (+ 2 n)) [1 2 3 4 5]) (3 4 5 6 7) user= (map (partial + 2) [1 2 3 4 5]) (3 4 5 6 7) user= I know that the answer is

Re: anonymous fn or partial?

2010-09-30 Thread Ulises
You can also consider the following: (map #(+ % 2) [1 2 3 4]), which I did consider #(...) but didn't include it in the example as I tend to prefer (fn [..] ...). For some reason my brain parses (fn...) much better than #() (it looks more explicit). If partial is a special case of #(..) could

Re: anonymous fn or partial?

2010-09-30 Thread Ulises
Think about it for a moment. What should  ((+ 2) 1)  return? A function with the next elment add on to it? So it would return a function that adds 3 to its args or the result? How can you know what the caller wants? That's a very good point which I hadn't considered. Perhaps the evaluation

Re: anonymous fn or partial?

2010-09-30 Thread Ulises
The two styles are ok. Matter of taste. (partial ...) have probably a slight cost I wouldn't worry about except if profiler tells me to worry. Excellent. If you want to have something looking like (+ 2) with multiple args possible, I would advocate the best way might be to add a reader