Re: using reduce instead of loop recur

2011-05-31 Thread Stuart Campbell
For this particular case, you could also use regexps: user> (require '[clojure.string :as s]) nil user> (s/replace " bb cc" #" +" " ") " bb cc" Regards, Stuart On 31 May 2011 08:15, iz bash wrote: > so clojures like my first programming language. most of the time > now ,i

How to create a library for java developers

2011-05-31 Thread finbeu
I'm using some legacy inhouse java libraries that are pretty complicated (lots of boilerplate and ugly code bloat to produce something useful). I would like to build a facade in clojure and provide a jar file so that this clojure facade can be easily used by java developers that do not know anythin

Re: Can't start Remote unmanaged REPL

2011-05-31 Thread Chas Emerick
I don't have Enclojure installed at the moment, but the error you're getting indicates that the jars you've pulled out do not contain the org.enclojure.repl.main class. You'll need the jar file that contains an entry at org/enclojure/repl/main.class. As a last resort, you could grab the source

Re: How to create a library for java developers

2011-05-31 Thread Ambrose Bonnaire-Sergeant
Hi Finn, On Tue, May 31, 2011 at 4:19 PM, finbeu wrote: > I would like to build a facade in clojure and > provide a jar file so that this clojure facade can be easily used by > java developers that do not know anything at all about clojure > (they're scared to death when I show them clojure code

Re: How to create a library for java developers

2011-05-31 Thread finbeu
Hi Ambrose, actually, I want to write this facade to learn how the java interop works. I'm still a beginner but calling java from clojure already works pretty good and I'm able to get things done faster with less code. The next step is then to make this clojure facade available for the java develo

Re: Radically simplified Emacs and SLIME setup

2011-05-31 Thread Matjaz Gregoric
Indeed, I switched from Vim to Emacs with Viper and Vimpulse and so far it has been a very pleasant experience, giving me best of both worlds. On Tue, May 31, 2011 at 4:18 AM, Joop Kiefte wrote: > And Emacs has Viper-mode (and other Vi-keybinding-stuff) :) > > 2011/5/30 J.R. Garcia : > > Having

Re: Dependencies with native components

2011-05-31 Thread Aaron Bedra
The main thing that we have run into is leiningen's inability to build a native dependency. We have a few projects where we had to build some wrappers and those have to be built and installed with a shell script before running leiningen. Is that in the pipeline? Cheers, Aaron Bedra -- Clojur

Clojure 1.3 - Embedding Java literal objects

2011-05-31 Thread David McNeil
I noticed the following behavior in Clojure 1.3 related to the new object literal syntax [1]: Clojure 1.3.0-master-SNAPSHOT user=> (defrecord Foo [a b]) user.Foo user=> (:a #user.Foo{:a 1 :b 2}) 1 user=> #java.awt.Point[10 20] # user=> (.getX #java.awt.Point[10 20]) CompilerException java.lang.Run

Re: Idiomatic use of records vs. maps

2011-05-31 Thread David McNeil
A couple of aspects of records that I have found useful: * they provide a type for dispatching. Rather than rooting around in the map to find out what it is, a multi-method can dispatch directly on the type of the object. * having a central definition of the main keys contained in the structure is

Re: fs and with-tempdir

2011-05-31 Thread Miki
Just uploaded fs 0.8.0 to clojars with your changes. Thanks! (I've changed the assert in your code to :pre checks) -- 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 m

Translating minikanren to core.logic

2011-05-31 Thread Ambrose Bonnaire-Sergeant
Hi, I'm playing around with the latest commit on core.logic with Clojure 1.2.1. There's a snippet of minikanren in the paper "Relational Programming in miniKanren: Techniques, Applications, and Implementations" that I'm having trouble translating. (Page 13, http://pqdtopen.proquest.com/#abstract

Re: Translating minikanren to core.logic

2011-05-31 Thread Ambrose Bonnaire-Sergeant
Whoops, I forgot to translate the literal list syntax to [] vector syntax. user=> (run 2 [q] (exist [x y z] (conde ((== [x y z x] q)) ((== [z y x z] q) ([_.0 _.1 _.2 _.0] [_.0 _.1 _.2 _.0]) Still puzzled at the semantics

Re: Translating minikanren to core.logic

2011-05-31 Thread David Nolen
On Tue, May 31, 2011 at 1:02 PM, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > user=> (run 2 [q] > (exist [x y z] >(conde > ((== (x y z x) q)) > ((== (z y x z) q) > You have to take note of the forma

Re: Translating minikanren to core.logic

2011-05-31 Thread David Nolen
On Tue, May 31, 2011 at 1:10 PM, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > From the paper: > > We use conde to get several values--syntactically, conde looks like cond >> but >> without => or else. > > > What does it mean by "get" several values? > > Thanks, > Ambrose > U

Re: How to create a library for java developers

2011-05-31 Thread Ken Wesson
Don't forget gen-interface. In fact, you may want to have just one gen-class with a static factory method, which produces an anonymous implementation of one of the interfaces, which is an abstract factory for making other objects that implement other interfaces. This provides the least coupling bet

Re: Idiomatic use of records vs. maps

2011-05-31 Thread Ken Wesson
On Tue, May 31, 2011 at 11:30 AM, David McNeil wrote: > A couple of aspects of records that I have found useful: > > * they provide a type for dispatching. Rather than rooting around in > the map to find out what it is, a multi-method can dispatch directly > on the type of the object. And you can

Re: Who's using Clojure?

2011-05-31 Thread Sean Corfield
On Tue, Apr 19, 2011 at 2:29 PM, Christopher Redinger wrote: > I've created a home to store the answer to this question. > http://dev.clojure.org/display/community/Clojure+Success+Stories ... > If you have successfully deployed Clojure code, let the world know. > Send an email with a brief (one pa

Announcement: stockings clojure library for easy access to financial data

2011-05-31 Thread fxt
Hi everyone, I just wanted to announce release 1.0 of my latest project: stockings. https://github.com/fxtlabs/stockings http://stockings.fxtlabs.com http://clojars.org/com.fxtlabs/stockings I mentioned some of this work to some of you at the last Bonjure (Montreal Clojure User Group) meeting, so

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

2011-05-31 Thread Ilya Kasnacheev
Hi *! I've tried a few searches on parsing XML files larger than memory, didn't find anything and wrote a simple framework for parsing XML via STAX to lazy sequence of defrecords. It is therefore capable of reading several GB of xml without much problems. It is quite declarative but also quite ugly

Re: Dependencies with native components

2011-05-31 Thread Phil Hagelberg
On May 31, 5:57 am, Aaron Bedra wrote: > The main thing that we have run into is leiningen's inability to build a > native dependency.  We have a few projects where we had to build some > wrappers and those have to be built and installed with a shell script > before running leiningen.  Is that in

Re: using reduce instead of loop recur

2011-05-31 Thread iz bash
thanks everyone!! that was really great help. -- 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 u

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

2011-05-31 Thread Ilya Kasnacheev
Forgot to mention some things: - https://github.com/alamar/clojure-xml-stream on github. - I'm yet to figure out that Lenin thing, so ant. - The two-step handler system (there's a function that takes a method and returns a handler, and handler accepts item being constructed and stream-reader) seem

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

2011-05-31 Thread Avram
Just a quick comment on a generic, similar issue. I need to parse Gigabyte files of multi-line JSON ( which is a similar problem to parsing Gigabytes of XML) where the record delimiter is not a newline. My strategy is to determine record separators (e.g. by counting the level of nestings) as chun

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 No

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

2011-05-31 Thread Avram
Interestingly, I had planned on using Jackson, but found that because my JSON data in fact was not always well-formed and needed minor cleaning steps (e.g. double newline without interleave commas between JSON chunks), I needed to create better chunks of well-formed JSON first in a streaming sort o

Re: Announcement: stockings clojure library for easy access to financial data

2011-05-31 Thread Andreas Kostler
I certainly will have a look. I'm working on a technical analysis library so you're lib will certainly be useful. Andreas On 01/06/2011, at 5:09 AM, fxt wrote: > Hi everyone, > > I just wanted to announce release 1.0 of my latest project: stockings. > https://github.com/fxtlabs/stockings > http

Re: using reduce instead of loop recur

2011-05-31 Thread Ken Wesson
On Tue, May 31, 2011 at 3:45 PM, iz bash wrote: > > thanks everyone!! that was really great help. You're welcome. Hopefully, reading and understanding the code posted here (not just mine) will both get you a better grasp of the various ways these kinds of things can be tackled using HOFs like ma

Retrieving individual maps (items) from a list.

2011-05-31 Thread mmwaikar
Hi, I've to use clojure.contrib.sql's insert-records fn. Usage: (insert-records table & records) Inserts records into a table. records are maps from strings or keywords (identifying columns) to values. So, for ex. this works - (clojure.contrib.sql/insert-records :blogs

Re: Retrieving individual maps (items) from a list.

2011-05-31 Thread Ambrose Bonnaire-Sergeant
Hi Manoj, On Wed, Jun 1, 2011 at 12:35 PM, mmwaikar wrote: > Hi, > > I've to use clojure.contrib.sql's insert-records fn. > > Usage: (insert-records table & records) > > Inserts records into a table. records are maps from strings or > keywords (identifying columns) to values. > > So, for ex. thi

Re: Retrieving individual maps (items) from a list.

2011-05-31 Thread Ken Wesson
On Wed, Jun 1, 2011 at 12:35 AM, mmwaikar wrote: > Hi, > > I've to use clojure.contrib.sql's insert-records fn. > > Usage: (insert-records table & records) > > Inserts records into a table. records are maps from strings or > keywords (identifying columns) to values. > > So, for ex. this works - >

Re: Retrieving individual maps (items) from a list.

2011-05-31 Thread Ken Wesson
On Wed, Jun 1, 2011 at 12:56 AM, Ken Wesson wrote: > On Wed, Jun 1, 2011 at 12:35 AM, mmwaikar wrote: > => [2 x :q] > [2 x :q] WTF? I wrote [2 42 :q] there, of course. What the devil happened to my email in transit? -- Protege: What is this seething mass of parentheses?! Master: Your father's L

Re: Retrieving individual maps (items) from a list.

2011-05-31 Thread Alan Malloy
insert-records is a function, so you should be able to just apply it? (apply insert-records :blogs (map #(zipmap [:a :b :c :d] %) [[1 2 3 4] [5 6 7 8]])) FWIW, the * notation around the parens makes it very difficult (for me) to read the code example. Just write

Idiomatic way to handle not existing map value

2011-05-31 Thread Andreas Kostler
Hi all, I find myself using the following pattern quite often: (assoc m :key (inc (or (:kay m) 0)) To increment or somehow transform a value in a map that I'm not sure it exists. Is there an idiomatic way of doing this sort of thing in a short and concise way? Kind Regards Andreas -- You rece

Re: Idiomatic way to handle not existing map value

2011-05-31 Thread Ken Wesson
On Wed, Jun 1, 2011 at 1:05 AM, Andreas Kostler wrote: > Hi all, > I find myself using the following pattern quite often: >  (assoc m :key (inc (or (:kay m) 0)) > > To increment or somehow transform a value in a map that I'm not sure it > exists. > Is there an idiomatic way of doing this sort of

Re: Idiomatic way to handle not existing map value

2011-05-31 Thread Andreas Kostler
Thanks Ken, I should have known the (m :key 0) solution as I've used that before :( Oh well :) Andreas On 01/06/2011, at 3:11 PM, Ken Wesson wrote: > On Wed, Jun 1, 2011 at 1:05 AM, Andreas Kostler > wrote: >> Hi all, >> I find myself using the following pattern quite often: >> (assoc m :key (i

Re: Idiomatic way to handle not existing map value

2011-05-31 Thread Ken Wesson
You're welcome. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You received this message because you are subscribed to the Google Groups "Cloj

Re: Idiomatic way to handle not existing map value

2011-05-31 Thread Laurent PETIT
For the record, you can also use fnil: => (defn mystery [m k] (update-in m [k] (fnil inc 0))) #'user/mystery => (mystery {} :a) {:a 1} => (mystery {:a 4} :a) {:a 5} 2011/6/1 Ken Wesson : > On Wed, Jun 1, 2011 at 1:05 AM, Andreas Kostler > wrote: >> Hi all, >> I find myself using the following pa

Re: Idiomatic way to handle not existing map value

2011-05-31 Thread Laurent PETIT
2011/6/1 Andreas Kostler : > Thanks Ken, > I should have known the (m :key 0) solution as I've used that before :( > Oh well :) => (:k {} 0) 0 works too > Andreas > > On 01/06/2011, at 3:11 PM, Ken Wesson wrote: > >> On Wed, Jun 1, 2011 at 1:05 AM, Andreas Kostler >> wrote: >>> Hi all, >>> I fi

Re: Idiomatic way to handle not existing map value

2011-05-31 Thread Alan Malloy
My preferred method is (update-in m [:key] (fnil inc 0)) On May 31, 10:05 pm, Andreas Kostler wrote: > Hi all, > I find myself using the following pattern quite often: >   (assoc m :key (inc (or (:kay m) 0)) > > To increment or somehow transform a value in a map that I'm not sure it > exists. >

Re: fs and with-tempdir

2011-05-31 Thread David Jagoe
Hey Miki, On 31 May 2011 17:52, Miki wrote: > Just uploaded fs 0.8.0 to clojars with your changes. Thanks! I'm glad to contribute something and I'll be glad to remove some code from my project! > (I've changed the assert in your code to :pre checks) Ah yes that sounds better. Cheers, David

Re: Retrieving individual maps (items) from a list.

2011-05-31 Thread Michael Wood
On 1 June 2011 07:00, Alan Malloy wrote: [...] > FWIW, the * notation around the parens makes it very difficult (for > me) to read the code example. Just write code as-is, and let the > reader notice that the parens are what's different (it's not hard). [...] The HTML part of the e-mail shows the