Re: Best way to (map) a sequence, but return 0-n items per input item?

2013-04-10 Thread Baishampayan Ghose
Does mapcat work? Or may be reduce with merge after the map? An example would help. ~BG On Thu, Apr 11, 2013 at 8:56 AM, Steven Degutis wrote: > The idea I already have in mind is to pass a function to map that returns a > sequence whose size can vary, and flatten the results of the map. > > This

Re: Best way to (map) a sequence, but return 0-n items per input item?

2013-04-10 Thread Steven Degutis
Wow, that works perfectly and it's really elegant! Glad I asked, thanks :) -Steven On Wed, Apr 10, 2013 at 10:32 PM, Andy Fingerhut wrote: > Since you are dealing with maps, this might not be exactly what you need, > but try it out and tweak it as needed: > > (mapcat f coll) = (apply concat (ma

ANN: Spyscope 0.1.3

2013-04-10 Thread David Greenberg
Spyscope is a library that allows you to write very little code to get threadsafe tracing of your Clojure. Example: (println #spy/d (+ 1 2 3)) traces the execution of the form '(+ 1 2 3) Spyscope also supports interactive querying of trace results with a repl toolkit (see README) This version of

Re: Best way to (map) a sequence, but return 0-n items per input item?

2013-04-10 Thread Andy Fingerhut
Since you are dealing with maps, this might not be exactly what you need, but try it out and tweak it as needed: (mapcat f coll) = (apply concat (map f coll)) Andy -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Best way to (map) a sequence, but return 0-n items per input item?

2013-04-10 Thread Steven Degutis
The idea I already have in mind is to pass a function to map that returns a sequence whose size can vary, and flatten the results of the map. This will probably work, but is there a more elegant way? What about more efficient? Note: the items returned will be Clojure maps. -Steven -- -- You

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 wrote: > Hello. I am replicating the study made by John D. Cook in > thispost about exact > chaos in Clojure, using rational arit

Re: [GSOC 2013] Android UI as Clojure Data

2013-04-10 Thread Dave Sann
Caveat - I haven't do any android dev and don't know details of their UI apis But not letting that get in the way of an opinion, I also suggest that you look at what Dave Ray has done with Seesaw for swing. There my well be useful ideas in there for you. https://github.com/daveray/seesaw/ in

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Cedric Greevey
Let me clarify. If the library's designed to interoperate specifically with a particular record type, it should be designed with knowledge of the base keys. Even then, its own keys should be ns-qualified. And it can't assume the set of base keys won't grow in a future version of the record type. Bu

Re: [GSOC 2013] core.match refactoring

2013-04-10 Thread crawfordpm
Thanks for the quick replies! I'll check out the Racket/Typed Racket implementations. Between that, the source, and the papers referenced in the notes, I'm certain I'll have a ton of questions. Thanks again, Patrick On Wednesday, April 10, 2013 4:33:47 AM UTC-4, David Nolen wrote: > > I thin

Re: New CSS library - Garden

2013-04-10 Thread Joel Holdbrooks
Awesome. Yes, please do! Also, feel free to suggest ideas for features. I'm focusing on media queries and "&" prefixed selectors this week, but I'd love to see if anyone has good ideas surrounding attribute and child selectors. Right now the best we can do is "input[type=\"text\"]" and "ul > li

Re: Good Clojure style?

2013-04-10 Thread Sean Corfield
I think I would have found it pretty hard to comprehend when I first started doing Clojure three years ago (eek - time flies!) but it made sense reading it today and it is pretty elegant. It certainly helps to know the rules of Conway's "Life"... I'm not sure I'd inflict this on my team members yet

lein search

2013-04-10 Thread Brian Craft
I'm unable to figure out "lein search". The query in the help text returns nothing: > lein search "clojure AND http AND NOT g:org.clojars*" > Searching for "h2" gives me 18 pages of unwanted results. "h2database" gives me nothing. "g:com.h2database" gives me nothing. "g:com.h2database*" gives

PPAML

2013-04-10 Thread Myriam Abramson
http://www.darpa.mil/Our_Work/I2O/Programs/Probabilistic_Programming_for_Advanced_Machine_Learning_%28PPAML%29.aspx I just went to the Proposer's day for this program this morning. It's more a programming language program than a machine learning program. They are interested in a probabilistic pro

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Alex Baranosky
If a library adds keys to foreign maps, those keys should be ns qualified IMO. On Wed, Apr 10, 2013 at 1:24 PM, Simon Katz wrote: > On Wednesday, 10 April 2013 21:08:22 UTC+1, Cedric Greevey wrote: > >> If a third-party library is storing things in your defrecord, it behooves >> its author to k

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
On Wednesday, 10 April 2013 21:08:22 UTC+1, Cedric Greevey wrote: > If a third-party library is storing things in your defrecord, it behooves > its author to know what that record's predefined keys are. > Um, I don't think I agree. The library might be doing something very generic and have no r

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Cedric Greevey
If a third-party library is storing things in your defrecord, it behooves its author to know what that record's predefined keys are. In fact, if a third-party library is putting (its own, rather than caller-supplied) keys into caller-supplied maps, it behooves it to use qualified keys. :) On Wed

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
I agree that things will be fine if the third-party code uses namespace-qualified keywords, but there can be clashes if the third-party library uses simple keywords. On Wednesday, 10 April 2013 20:55:18 UTC+1, Cedric Greevey wrote: > > I don't think that creates a need for qualified defrecord "b

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Cedric Greevey
I don't think that creates a need for qualified defrecord "base keys" (the [x y z] in your example) though. Those keys are all from one origin: the piece of code with the defrecord itself in it. That piece is defining the data type and it stands to reason that it be privileged to specify unqualifie

Re: New CSS library - Garden

2013-04-10 Thread Dan Neumann
Good stuff! I'm using it in my hobby apps while I continue to cut my teeth on Clojure's web development toolkit. I'll definitely communicate any problems/improvements I spot as I try to scratch my own itch. -- -- You received this message because you are subscribed to the Google Groups "C

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
Yes. That concept of a promiscuous map (great name) is what I'm trying to get at. On Wednesday, 10 April 2013 20:30:52 UTC+1, Cedric Greevey wrote: > > The main use for qualified keywords that occurs to me is if you have a > "promiscuous map" that will be holding key/value pairs submitted by >

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
On Wed, Apr 10, 2013 at 2:13 PM, Jim foo.bar wrote: > On 10/04/13 14:03, Simon Katz wrote: > >> Second, Clojure supports namespace-qualified keywords, presumably because >> it's possible that different libraries might want to use the same keyword >> for different purposes. >> > > I don't think th

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Alex Baranosky
Or keys your library adds to a var, for instance. On Wed, Apr 10, 2013 at 12:30 PM, Cedric Greevey wrote: > The main use for qualified keywords that occurs to me is if you have a > "promiscuous map" that will be holding key/value pairs submitted by > multiple pieces of code of distinct origins.

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Cedric Greevey
The main use for qualified keywords that occurs to me is if you have a "promiscuous map" that will be holding key/value pairs submitted by multiple pieces of code of distinct origins. A big registry of preferences that can be added to by plugins would be an example, with qualified keywords making i

[GSOC 2013] Android UI as Clojure Data

2013-04-10 Thread Junseok Lee
Hello! My name is Junseok Lee, and I'm studying CS at UC Berkeley. I was lead to Clojure through my interest in the Lisp family of languages, initiated by my studies of Scheme in my coursework. I've been lurking on this group for a while and thought it was about time to introduce myself. I'm ho

Re: Good Clojure style?

2013-04-10 Thread Alex Baranosky
IMO, t the end of the day, if the code isn't immediately readable (for other people on your team, which means what I'm saying is context dependent), then it needs to be made clearer. That is *always* going to be a value judgement. But I've heard the same comment about that particular Game of Life

Re: [ANN] Instaparse 1.0.0

2013-04-10 Thread Mark Engelberg
On Wed, Apr 10, 2013 at 12:22 AM, sesm wrote: > Hi Mark, > > Amazing stuff, I didn't know, that such general parsing techniques even > exist! > > One minor comment: it would be nice to add direct links to GLL papers and > https://github.com/epsil/gll github repo to save people some googling > tim

Re: Good Clojure style?

2013-04-10 Thread Mark
I agree that this seems a bit terse and magical. However, there are a couple of mitigating factors to consider. 1. frequencies is a Clojure core function. It's simple enough to understand on its own, but if you haven't encountered it, you'd need to look it up to be sure what it's returning. Som

Re: Good Clojure style?

2013-04-10 Thread Erlis Vidal
But I think you have mixed two different issues: code style vs readability. For code style I'll suggest the github page https://github.com/bbatsov/clojure-style-guide which offer a very nice compilation. Now for readability I would say that you can be entering in a very gray zone here. Lisp code

[ANN] Clearley

2013-04-10 Thread Mike Thvedt
ANN: Clearley 0.2.0 https://github.com/mthvedt/clearley Yet another Clojure parser library. Clearley is a parser for people who aren't interested in parsing, and just want to get up and running as quickly as possible processing streams of structured data. Bullet points: * No need to fool aro

Re: Good Clojure style?

2013-04-10 Thread Softaddicts
This single snippet does not look too obscure to me. I have the book but never read this part. >From what I can see, it gets a list of neighbors from the current state in >cells, extract pairs of location/frequency (de structuring loc and n for each pair returned by frequencies) and returns cells

Re: Good Clojure style?

2013-04-10 Thread Alex Baranosky
That said the code probably only needs a couple meaningfully-named private functions to help make it more immediately obvious what it is doing, imo. On Wed, Apr 10, 2013 at 10:39 AM, Alex Baranosky < alexander.barano...@gmail.com> wrote: > It isn't just you. It is not easy for me to see how thi

Re: Good Clojure style?

2013-04-10 Thread Alex Baranosky
It isn't just you. It is not easy for me to see how this code works, until I think about it for a while. In code review that'd be my main concern. No offense to the author, because the implementation is actually really neat. :) On Wed, Apr 10, 2013 at 10:27 AM, wrote: > So, page 143 of Cloju

Good Clojure style?

2013-04-10 Thread edward
So, page 143 of Clojure Programming has an implementation of Conway's Life: (defn step "Yields the next state of the world" [cells] (set (for [[loc n] (frequencies (mapcat neighbours cells)) :when (or (= n 3) (and (= n 2) (cells loc)))] loc))) The book claims this to be "an elegant

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Jim foo.bar
On 10/04/13 14:03, Simon Katz wrote: Second, Clojure supports namespace-qualified keywords, presumably because it's possible that different libraries might want to use the same keyword for different purposes. I don't think that is the reason for having namespace-qualified keywords...different

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
Replying to myself... Hmmm, of course, defining that function wouldn't solve the problem of clashes. On Wednesday, 10 April 2013 14:03:47 UTC+1, Simon Katz wrote: > > I'm wondering how two things fit together (and I suspect they don't). > > First, if I define a record type, e.g. > (defrecord F

defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
I'm wondering how two things fit together (and I suspect they don't). First, if I define a record type, e.g. (defrecord Foo [x y z]) I can access fields using keywords as functions: (:x (->Foo 1 2 3)) => 1 Second, Clojure supports namespace-qualified keywords, presumably because it's possibl

[GSOC 2013] Clooj IDE/Suggestions

2013-04-10 Thread Joe Nash
Hi there, I would be interested in working on this project. What would be the best way for me to contact Arthur to see if he would be interested in mentoring? Failing that, is anyone else interested in mentoring improvements to Clooj? I'm also interested in pretty much anything PLT based and have

Re: [ANN] Instaparse 1.0.0

2013-04-10 Thread Arnout Roemers
Wow, an amazing parser with good documentation indeed. I had a go myself at a parser using a BNF-like syntax as well (https://github.com/aroemers/crustimoney), but I guess this project supersedes it by far (although my parser does use programmatic data structures for the grammar, without using

Re: Leiningen exception when run inside a project

2013-04-10 Thread David Powell
Btw - I have created an installer for leiningen on Windows, that makes sure that your JDK is set up properly. http://leiningen-win-installer.djpowell.net On Wed, Apr 10, 2013 at 10:30 AM, Dmytro Kozhukhar wrote: > SOLVED > > Just installed JDK instead of JRE and it works ok. > > > On Wed, Apr 1

Re: Leiningen exception when run inside a project

2013-04-10 Thread Dmytro Kozhukhar
SOLVED Just installed JDK instead of JRE and it works ok. On Wed, Apr 10, 2013 at 12:09 PM, Dmytro Kozhukhar wrote: > It does not seem so, I tried this on new project, created with 'lein new > app helloworld' > it has source generated by lein in ./src/helloworld/core.clj : > > (ns helloworld.co

Re: Leiningen exception when run inside a project

2013-04-10 Thread Dmytro Kozhukhar
It does not seem so, I tried this on new project, created with 'lein new app helloworld' it has source generated by lein in ./src/helloworld/core.clj : (ns helloworld.core (:gen-class)) (defn -main "I don't do a whole lot ... yet." [& args] ;; work around dangerous default behaviour in

Re: Leiningen exception when run inside a project

2013-04-10 Thread Adam Clements
Your project.clj probably has unmatched brackets, this error means it hit the end of a file it was reading while still scanning for a closing bracket. On 10 Apr 2013 09:22, "Dmytro Kozhukhar" wrote: > Hello everyclojurer! > > Today I have problem with installing lein on WinXP. > > Lein run just f

Re: [GSOC 2013] core.match refactoring

2013-04-10 Thread David Nolen
I think there are a variety of Clojure/ClojureScript projects here and there that use core.match. It hasn't gotten as much uptake as I would like as there are issues around AOT which I would like to see addressed. I agree with Ambrose that looking at Racket's pattern matching facilities would be i

Re: [ANN] Instaparse 1.0.0

2013-04-10 Thread sesm
Hi Mark, Amazing stuff, I didn't know, that such general parsing techniques even exist! One minor comment: it would be nice to add direct links to GLL papers and https://github.com/epsil/gll github repo to save people some googling time. -- -- You received this message because you are subscr

Leiningen exception when run inside a project

2013-04-10 Thread Dmytro Kozhukhar
Hello everyclojurer! Today I have problem with installing lein on WinXP. Lein run just fine in any folder, except it is a folder with project. If I run 'lein repl' or 'lein run' then I get this error: D:\lein\helloworld>lein run Exception in thread "main" clojure.lang.LispReader$ReaderException