Re: core.cache 0.6.2 is not available from Central

2012-08-08 Thread Andreas Kostler
> Given that regular Clojure users cannot submit a pull request. Really? That's what I did... On 9 August 2012 06:56, Michael Klishin wrote: > Meikel Brandmeyer: > > > This does not necessarily include a specific version. > > “Instructions for including the library as a dependency in Maven / >

Re: Advice needed on primitive longs and trying to avoid autoboxing

2012-07-12 Thread Andreas Kostler
To answer your last question, I'd probably do it like this: (def bitvector (reduce (fn [bm x] (conj bm (expt 2 x))) [] (range 63))) ;; Remember, vectors implement ifn. Also, I believe using the bitshift operator (arguably) obscures your intentions without much benefit over expt. As to answering y

Announcing dyscord

2012-07-02 Thread Andreas Kostler
Hi all, A little exercise to get me started with clojurescript turned into something people might actually find useful: dyscord, a clojurescript library to bring emacs-like key sequences to web-apps. usage = A key sequence, is a sequence of keyboard key presses. Any element in such a sequenc

Re: Enfocus issues

2012-06-14 Thread Andreas Kostler
There you go...wrong on the example-page then. Thanks David On 15 June 2012 15:00, David Nolen wrote: > On Fri, Jun 15, 2012 at 1:23 AM, Andreas Kostler < > andreas.koest...@leica-geosystems.com> wrote: > >> (set! (.onload js/window) start) > > > Should be (s

Enfocus issues

2012-06-14 Thread Andreas Kostler
Hi everyone, I finally decided to give clojurescript a spin. Unfortunately, the momentum died before I even got the ball running. I'm trying to replicate the canonical example on the enfocus website using lein-cljsbuild [0.2.1] and enfocus [0.9.1-SNAPSHOT]: (ns my.namespace (:require [enfocus.c

Re: Let over Lambda

2012-05-17 Thread Andreas Kostler
It treats reader macros in some detail which is not really applicable to Clojure but it's a fun book :) On 18 May 2012 11:53, P Martin wrote: > Hi everyone, > I was perusing Amazon for some books on Clojure and Lisp and came across > Let Over Lambda. From its reviews, it seems that this book may

Re: Compilation model

2012-02-23 Thread Andreas Kostler
Bump...I'm interested in this, too... On 21 February 2012 12:29, T.Y Chew wrote: > > > Hi all, > > I had a question about clojure's compilation model, which my co-worker > suggest to redirect here :-) > > I wonder what clojure does during compilation of a file? Can > side-effects occur (definiti

Re: Problem with amap over byte arrays

2012-02-16 Thread Andreas Kostler
How stupid of me. Cheers On 17 February 2012 12:12, dennis zhuang wrote: > Because bit-xor returns a integer,so you have to cast it to byte: > > > (amap ^bytes an-array > idx > ret > (byte (bit-xor (byte 0) > (aget ^bytes an-array idx > > > 2

Problem with amap over byte arrays

2012-02-16 Thread Andreas Kostler
Hi all, I'm experiencing the following problem: (def an-array (byte-array 200 (byte 1))) (amap ^bytes an-array idx ret (bit-xor (byte 0) (aget ^bytes an-array idx))) Resulting in: No matching method found: aset Wheras this: (def another-array (int-array 200 (int 1))) (amap ^

Re: Calling all Melbourne, Australia, Clojure users

2012-02-12 Thread Andreas Kostler
Hi all, We have a similar group here in Adelaide "Forum for functional programming practioners, from beginner to advanced. All languages, all welcome." @ http://www.meetup.com/acsafp/ It's nice to see groups like this are getting traction in Australia. Cheers Andreas On 9 February 2012 22:29, J

Re: Thin clojure wrapper for zeromq

2011-12-18 Thread Andreas Kostler
q.3x (only 2.x series). > > Sorry about that, > B. > > On Dec 18, 6:10 pm, Andreas Kostler > wrote: >> Hi All, >> For a little hobby project I found myself looking for a clojure >> wrapper for 0MQ. clojure-zeromq is stale and doesn't support zeromq > >>

Thin clojure wrapper for zeromq

2011-12-18 Thread Andreas Kostler
Hi All, For a little hobby project I found myself looking for a clojure wrapper for 0MQ. clojure-zeromq is stale and doesn't support zeromq > 3.0.0 so I rolled my own: https://github.com/AndreasKostler/clj-0MQ It's in a very early stage of development but most of the functionality is there. Furthe

Re: Literate Programming in Emacs?

2011-11-22 Thread Andreas Kostler
It should work as expected if you follow http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html and use the stand-alone version of swank-clojure (Section Connecting with SLIME https://github.com/technomancy/swank-clojure). Looking at ob-clojure.el http://kanis.fr/hg/lisp/org/ob-clo

Re: Getting index of char from end

2011-11-13 Thread Andreas Kostler
How about using the clojure sequence functions? (require '[clojure.contrib.seq-utils :as seq-utils]) (defn last-index-of [c string] (first (seq-utils/find-first (fn [[_ a]] (= a c)) (reverse (seq-utils/indexed string) P.S. Jong Won, how are you liking Clojure? I've met you in Parramatta and

Re: Getting index of char from end

2011-11-13 Thread Andreas Kostler
amatta and joined the ADO team :) Nice to have you on the group here :) Cheers Andreas On Nov 13, 6:54 pm, Andreas Kostler wrote: > How about using the clojure sequence functions? > (require '[clojure.contrib.seq-utils :as seq-utils]) > > (defn last-index-of [c string] >  (f

Re: Stanford Dabatabase Class Begins Tomorrow

2011-10-09 Thread Andreas Kostler
I am :) On 10 October 2011 04:02, Harrison Maseko wrote: > The Stanford "Introduction to Databases" class officially starts > tomorrow, October 10, 2011. I have enrolled and look forward to this > nine-week online course. I was wondering if anyone on this list is > taking it. It will be encouragi

Re: Does macros evaluates its arguments before?

2011-09-27 Thread Andreas Kostler
This is quite amusing since the first reply to the original post already provided the correct answer :) On Sep 28, 2011 6:05 AM, "Michał Marczyk" wrote: > Hi Ru, > > let's input your macro definition at the REPL: > > user> (defmacro infix [e] `(let [[x# f# y#] ~e] (f# x# y#))) > #'user/infix > > S

Re: suggestion for clojure development

2011-09-27 Thread Andreas Kostler
I'm with Phil on that one. Legacy support slows or even hinders innovation. On Sep 28, 2011 6:06 AM, "Phil Hagelberg" wrote: > On Tue, Sep 27, 2011 at 11:57 AM, Arthur Edelstein > wrote: >> So my request for Clojure's future development, is that backwards >> compatibility not be broken. This mean

Re: small project to learn clojure

2011-09-18 Thread Andreas Kostler
If Robocode is fun to you, why not do that then: http://nakkaya.com/2010/07/06/controlling-robocode-engine-from-clojure/ http://www.fatvat.co.uk/2009/05/clojure-and-robocode.html There's also been a thread on this group about the same topic a while ago. Hope this helps Andreas On 19 September 201

Re: Thoughts on CUDA + Clojure

2011-09-08 Thread Andreas Kostler
Dissecting PyCuda might give you a headstart :) On 9 September 2011 06:05, Michael Jaaka wrote: > Why not to translate to any lang? I though about translating clojure > to php source code. It differs from jvm and crl (.net) approach that > it is not translated to uni language to be run on one pl

Re: Documentation For Lisp Programming in Clojure.

2011-09-04 Thread Andreas Kostler
Sicp, the little schemer, seasoned schemer,norvigs paradigms of AI programming. Seibels practical common lisp. Let over lambda. More Cl specific is Sonja Kleenex PO programming in Cl or the metaobject protocol. And there's more On Sep 4, 2011 4:48 AM, "octopusgrabbus" wrote: > I have seen the thr

Re: clojure-based non-blocking webserver like Node.js

2011-09-03 Thread Andreas Kostler
Can someone explain please what class threads are?? And whether is threads are expensive depends on the is On Sep 3, 2011 5:09 AM, "Raoul Duke" wrote: > On Fri, Sep 2, 2011 at 11:20 AM, billh2233 wrote: >> I like Node.js's non-blocking IO for performance reasons, though it is >> built around a

Re: "Elegant tools deserve elegant solutions." -- L. E. Gant

2011-08-08 Thread Andreas Kostler
Hi Tuba, I don't quite understand what you mean by "I’m having a hard time thinking through the process of generating the candidate suffix set using set forms" but I have created a porter stemmer for English in the past. I understand that's not what you're looking for but it is moreso a framwork fo

Re: Threading operator generalisation

2011-07-18 Thread Andreas Kostler
You're not discouraging...It's just mailing list 'etiquette' to check if some topic has been discussed before, I guess :) On 19/07/2011, at 3:26 PM, Sean Corfield wrote: > On Mon, Jul 18, 2011 at 10:19 PM, Andreas Kostler > wrote: >> I've posted t

Re: Threading operator generalisation

2011-07-18 Thread Andreas Kostler
eld wrote: > On Mon, Jul 18, 2011 at 9:57 PM, Andreas Kostler > wrote: >> Hmm...I didn't get Chas' reply...Was that a private response? > > No, it probably just hasn't gotten to everyone yet...? I see it on the web: > > http://groups.google.com/group/clojure/br

Re: Threading operator generalisation

2011-07-18 Thread Andreas Kostler
I just realised I'm missing quite a few of the replies...including Kens. I've gotta follow the web list more closely. Andreas On 19/07/2011, at 3:12 PM, Sean Corfield wrote: > On Mon, Jul 18, 2011 at 9:57 PM, Andreas Kostler > wrote: >> Hmm...I didn't get Chas&

Re: Threading operator generalisation

2011-07-18 Thread Andreas Kostler
Hmm...I didn't get Chas' reply...Was that a private response? I sometimes feel I miss out on certain replies to the group. Cheers Andreas On 19/07/2011, at 2:55 PM, Sean Corfield wrote: > On Mon, Jul 18, 2011 at 7:04 PM, Chas Emerick wrote: >> Just as a general comment: just because any of our

Re: converting a string into a set

2011-07-18 Thread Andreas Kostler
In that case you don't need to convert to a symbol... (set "abc") should be fine... Using set intersection, something like this is probably what you're looking for... (use 'clojure.set) (if (empty? (intersection (set "abc") (set "cde"))) false true)) I'm sure there's other (better) ways though

Re: Threading operator generalisation

2011-07-18 Thread Andreas Kostler
Mon, Jul 18, 2011 at 6:51 PM, Andreas Kostler > wrote: >>> (-> "x" >>>(#(str "y" % "z")) >>>(#(str "a" % "b")) >>>println) >> Here, the meaning of % changes?!? > > Not really, ea

Re: converting a string into a set

2011-07-18 Thread Andreas Kostler
I'm with Benjamin despite my last post... On 19/07/2011, at 2:31 PM, Benjamin Esham wrote: > Tuba Lambanog wrote: > >> Tuba Lambanog wrote: >> >>> Hello, My apologies for this newbie question. I couldn't find a way to >>> convert a string to a set, thus: >>> >>> "abc" => #{a b c} >> >> (set "a

Re: converting a string into a set

2011-07-18 Thread Andreas Kostler
On 19/07/2011, at 2:29 PM, Sean Corfield wrote: > On Mon, Jul 18, 2011 at 9:17 PM, Tuba Lambanog > wrote: >> (set "abc") >> gives me #{\a \b \c}. >> I'm expecting instead: #{a b c} > > (set (map "abc")) > > (set (map str "Tuba Lambanog")) This will produce #{"a" "b" "c"} I think (set (map

Re: Threading operator generalisation

2011-07-18 Thread Andreas Kostler
On 19/07/2011, at 11:47 AM, Sean Corfield wrote: > On Mon, Jul 18, 2011 at 5:41 PM, Andreas Kostler > wrote: >> Ups, I'm not aware of that thread...I just found a more general threading >> operator handy sometimes. >> I do kinda agree that we shouldn't

Re: Threading operator generalisation

2011-07-18 Thread Andreas Kostler
ct that whatever symbol is > used for the binding position then becomes a "varying" thing within > the expression: > > (-newthread-> "x" > (str "y" :? "z") > (str "a" :? "b") > println) &g

Threading operator generalisation

2011-07-18 Thread Andreas Kostler
Maybe you might find this useful (defmacro -> ([x] x) ([x form] (if (seq? form) (with-meta (replace {:? x} form) (meta form)) (list form x))) ([x form & more] `(-> (-> ~x ~form) ~@more))) This allows for a more flexible threading

Re: Recommendation for Clojure Enterprise Development toolkit

2011-07-09 Thread Andreas Kostler
What is generally considered "enterprise" then? On 10/07/2011, at 9:07 AM, Sean Corfield wrote: > In which case, apologies to Shree... but those lists don't really > offer many companies that would generally be considered "enterprise" > so I'm not sure how persuasive they would be (in either dire

Re: rand-nth throwing an exception

2011-06-13 Thread Andreas Kostler
Hi Jarek, Sometimes you want an exception to be thrown if an element in a collection is not available, sometimes you want to deal with nil. I guess it depends on your application of whether you'd go with get or nth. There's no wrong or right here. Andreas On 13 June 2011 17:51, Jarek Siembida wr

Re: rand-nth throwing an exception

2011-06-12 Thread Andreas Kostler
Hi Jarek, Have a look at the clojure documentation: nth Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences. Unfortunately,

Hierarchical Agglomerative Clustering

2011-06-06 Thread Andreas Kostler
Hi all, Please find below my take on the hac algorithm. I'd like to hear how I could improve on it. Especially the get-closest-pair function is ugly. I also don't like that I need transform the cluster to something vijual can draw. It would be much nicer to simply represent the tree as a neste

Re: Parsing HTML in clojure

2011-06-05 Thread Andreas Kostler
There's a Java library called HtmlCleaner. You might wanna give that a shot. Btw, I'm working on quite a similar project so if you like email me and we can maybe join forces. Andreas On 06/06/2011, at 11:01 AM, Base wrote: > hi all, > > I am working on an app that will parse web pages to do so

Re: Stout

2011-06-02 Thread Andreas Kostler
Yes, soon programming clojure will be like a night out in town... On 02/06/2011, at 4:31 PM, David Jagoe wrote: > Well I like the name! > > On 2 June 2011 06:21, Andreas Kostler > wrote: >> Hi All, >> >> Stout is a porter stemmer implemention using a snowbal

Stout

2011-06-01 Thread Andreas Kostler
Hi All, Stout is a porter stemmer implemention using a snowball-like syntax for defining rules. Rules are of the form {:c? condition :s1 "abc" :s2 "efg" :a action} reading if condition is met, replace s1 with s2 and execute action. ## Usage (use 'stout.porter-stemmer) (map porter-stemmer coll

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 o

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: 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: Aw: Re: Aw: Protocol issues

2011-05-30 Thread Andreas Kostler
Meikel, Adding import A to ns c did the trick! Thanks a lot. Andreas On 30/05/2011, at 10:42 PM, Meikel Brandmeyer wrote: > Hi, > > still works for me, although your c has a missing (:import a.A). Would you > mind posting the actual code with the true types stripped-down to the > minimum? Or

Re: Aw: Protocol issues

2011-05-30 Thread Andreas Kostler
My bad, I'm calling foo in yet another namespace: (ns c (:use b)) (def x (A. 1 2)) (bar x) and that's when I get: Throws: No single method: bar of interface: b.Foo found for function: bar of protocol: Foo [Thrown class java.lang.IllegalArgumentException] Cheers Andreas On 30/05/2011, at 10:

Protocol issues

2011-05-30 Thread Andreas Kostler
Hi all, I have two clj files with two namespaces: a.clj (ns a) (defrecord A [a b]) b.clj (ns b (:import [a A])) (defprotocol Foo (bar [s])) (extend-type A Foo (bar [s] (println s))) (def x (A. 1 2)) (bar x) Throws: No single method: bar of interface: b.Foo found for function: bar of

Re: Matrix operation (a la numpy)

2011-05-28 Thread Andreas Kostler
I'm not 100% sure but I think Incanter has matrix ops. Andreas On 28/05/2011, at 7:15 PM, JuanManuel Gimeno Illa wrote: > I'm looking for a clojure library to perfomr matrix manipulation a la numpy. > The best candidate I've found is infer.matrix but I wonder if there is a > hidden jewel to dis

Re: Recur and primitives?!?

2011-05-26 Thread Andreas Kostler
The question is though, why doesn't this work to begin with and why does it work on 1.3.0-master-SNAPSHOT...? Is it broken or am I doing something wrong? :) Andreas On 27/05/2011, at 1:28 PM, Ken Wesson wrote: > On Thu, May 26, 2011 at 10:28 PM, Armando Blancas > wrote: >> Coercing m to int so

Re: Efficient sparse vector representation...

2011-05-26 Thread Andreas Kostler
quite in favour of sparse-vecs (~ 4 times faster than map based implementations). Obviously, assoc on a map is way faster than the sparse-vec implementation of assc below... Kind Regards Andreas On 27/05/2011, at 11:11 AM, Ken Wesson wrote: > On Thu, May 26, 2011 at 8:50 PM, Andreas Kostl

Re: Efficient sparse vector representation...

2011-05-26 Thread Andreas Kostler
s clearer as well. Cheers Andreas On 26/05/2011, at 11:11 PM, Ken Wesson wrote: > On Thu, May 26, 2011 at 8:19 AM, Andreas Kostler > wrote: >> (let [new-indices (sort (conj indices i)) >>new-idx (bin-search new-indices i) >>

Recur and primitives?!?

2011-05-26 Thread Andreas Kostler
Hi guys, I'm kinda lost as to what's going on here...With clojure-1.2.0 (defn bin-search [v k c] (loop [l 0 h (dec (count v))] (if (> l h) false (let [m (quot (+ l h) 2) m-v (v m)] (cond (> m-v k) (recur (inc m) h) (> k m-v) (recur l

Re: Efficient sparse vector representation...

2011-05-26 Thread Andreas Kostler
indices i) 0))) Can you guys think of ways of making this more idiomatic and/or performant? Cheers Andreas On 26/05/2011, at 1:12 PM, Ken Wesson wrote: > On Wed, May 25, 2011 at 10:22 PM, Andreas Kostler > wrote: >> Yes and no. I need efficient two way lookup. >> >&g

Re: finding a key which does not exist in the map

2011-05-26 Thread Andreas Kostler
If you have control over the creation of the map, you could use something like a global counter to provide the next valid key. You could also use a sorted map and just increment to last (biggest) key in the map. Or you could use a random number. If the range is big enough, the probability of col

Re: Efficient sparse vector representation...

2011-05-25 Thread Andreas Kostler
On that note, is there an easy way of measuring memory usage? Andreas On 26/05/2011, at 1:12 PM, Ken Wesson wrote: > On Wed, May 25, 2011 at 10:22 PM, Andreas Kostler > wrote: >> Yes and no. I need efficient two way lookup. >> >> So, I need to do something like >&g

Re: Efficient sparse vector representation...

2011-05-25 Thread Andreas Kostler
On 26/05/2011, at 1:12 PM, Ken Wesson wrote: > On Wed, May 25, 2011 at 10:22 PM, Andreas Kostler > wrote: >> Yes and no. I need efficient two way lookup. >> >> So, I need to do something like >> For every key in {12 "a" 23 "aa" 234 "&

Re: Efficient sparse vector representation...

2011-05-25 Thread Andreas Kostler
token-> id. So I can get to the id of a word vial (token-map token) If I now have a map of {id1 token1 id1 token2 ... } On 26/05/2011, at 12:00 PM, Alan Malloy wrote: > I think you've reinvented hashmaps: > > {12 "a" 23 "aa" 25 "aaa" 234 "a

Efficient sparse vector representation...

2011-05-25 Thread Andreas Kostler
Hi all, has anyone spent some thought on how to efficiently represent sparse vectors in Clojure? A naive scheme I came up with is using a vector of [idx val] pairs, e.g.: (def sparse-vec [[12 "a"][23 "aa"][25 "aaa"][234 ""]]) Accessing a value at an idx can be done so: (get-nth sparse-vec 25)

Re: List comprehension and sets

2011-05-24 Thread Andreas Kostler
Hi, try (set (for [x (range 4)] (* x 4))) Cheers Andreas On 24/05/2011, at 8:40 PM, MarisO wrote: > Is it possible to use list comprehension to generate a set ? > For example in scala I can do: > > for (i <- (2 to 8).toSet[Int]) yield p(i) > > In clojure this > > (for [ x (set (range 4))]

Re: lein and private locally installed classes

2011-05-24 Thread Andreas Kostler
lein install or mvn mvn install:install-file -DgroupId=blub -DartifactId=blub -Dversion=1 -Dpackaging=jar -Dfile=/path/to/file On 24/05/2011, at 5:55 PM, Eric S Fraga wrote: > Hello, > > I've trawled the 'net etc. but have not been able to find the answer to > a simple question: how can I tell

Re: Clojure example code snippets

2011-05-19 Thread Andreas Kostler
Hi Armando, I'm working on a Clojurej library for sentiment analysis which doesn't contain everything you'd want for nlp but quite a nice subset of input modules (plain text corpora, rss feeds, html, etc...), tokenising/normalising filters (noise removal, porter stemmer, etc), distance/similarit

Efficient moving average

2011-05-09 Thread Andreas Kostler
Hi all, I'm trying to calculate the moving average of a certain window size. One straight forward approach is: (defn lazy-avg [coll] (let [[sum cnt] (reduce (fn [[v c] val] [(+ val v) (inc c)]) [0 0] coll)] (if (zero? cnt) 0 (/ sum cnt)

Request for feedback: Tradui

2011-05-08 Thread Andreas Kostler
Hi all, I've started development on tradui, a translator for the Creole markup language. It is not finished or in any deployable shape or form yet, however it's progressed enough to gather some feedback on the approach taken. Please feel free to clone https://github.com/AndreasKostler/tradui.git an

Re: Where's incanter chrono?

2011-05-08 Thread Andreas Kostler
Cheers :) On 08/05/2011, at 8:17 PM, Edmund Jackson wrote: > I think the code has been under development and is now here: > https://github.com/getwoven/clj-time as clj-time. > > On 8 May 2011, at 05:53, Andreas Kostler wrote: > >> Hello all, >> Has incanter.

Where's incanter chrono?

2011-05-07 Thread Andreas Kostler
Hello all, Has incanter.chrono disappeared? (use '(incanter core chrono)) results in Could not locate incanter/chrono__init.class or incanter/chrono.clj on classpath: [Thrown class java.io.FileNotFoundException] For both incanter 1.2.3 and incanter 1.2.2 Cheers Andreas -- You received this me

Request for feedback: Tradui

2011-05-07 Thread Andreas Kostler
Hi all, I've started development on tradui, a translator for the Creole markup language. It is not finished or in any deployable shape or form yet, however it's progressed enough to gather some feedback on the approach taken. Please feel free to clone https://github.com/AndreasKostler/tradui.git

Re: Adding key values in a list of maps

2011-04-14 Thread Andreas Kostler
Or: (reduce #(+ %1 (:b %2)) 0 p) :) On Apr 15, 10:51 am, Andreas Kostler wrote: > (reduce + (map :b p)) > Cheers > Andreas > > On 15 April 2011 10:43, Bhinderwala, Shoeb > wrote: > > > > > > > > > > >  I am a beginner in Clojure. > > >

Re: Adding key values in a list of maps

2011-04-14 Thread Andreas Kostler
(reduce + (map :b p)) Cheers Andreas On 15 April 2011 10:43, Bhinderwala, Shoeb wrote: > I am a beginner in Clojure. > > I have a list of maps: > > (def p '({:a 1 :b 2 :c 4}, {:a 2 :b 3 :c 5}, {:a 3 :b 4 :c 6})) > > How do I add up all the :b values in the map? Result should be 9 (=2+3+4) > > I

Erlangs Bin for Clojure

2011-04-13 Thread Andreas Kostler
I'm quite impressed with Erlang's Bin datatype and binary pattern matching. I've tried to replicate some of the coolness in Clojure.. So, what can you do with it? Create a bin: user> (<< 1 17 42) (1 17 42) user> (<< [0xf0f0 16] 1 17) (240 240 1 17) user> (<< "abc") (97 98 99) Mo

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Andreas Kostler
There you go, symmetry and simplicity :) On 04/04/2011, at 6:35 AM, Alan wrote: > Isn't all this just a special case of partition-by? > > (defn drop-by [f coll] > (apply concat (rest (partition-by f coll > > (defn take-by [f coll] > (first (partition-by f coll))) > > user> (drop-by (part

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Andreas Kostler
Hi Stefan, I am overwhelmed by the 'freedom of choice' Clojure gives you, too. In that respect it's more like ruby than python. Nevertheless, I think if you can come up with an algorithm using the built in functions over sequences like map, reduce, filter, etc. you should do so. Either way, it

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Andreas Kostler
I can't answer that Ken, I guess I wasn't thinking of vec when I wrote it :) On 03/04/2011, at 5:17 PM, Ken Wesson wrote: > On Sun, Apr 3, 2011 at 1:04 AM, Andreas Kostler > wrote: >> (map (fn [x y] [x y]) coll (rest coll)) > > What's you

Re: clojure.core/some expected behaviour

2011-04-02 Thread Andreas Kostler
Thanks Daniel, I should have worked that out myself ;) Andreas On 03/04/2011, at 3:47 PM, Daniel Janus wrote: > On 3 Kwi, 07:37, Andreas Kostler > wrote: > >> Hi Daniel, >> Thanks for your reply. I know how to get to :fred. >> I'm just wondering why some wouldn&

Re: clojure.core/some expected behaviour

2011-04-02 Thread Andreas Kostler
Hi Daniel, Thanks for your reply. I know how to get to :fred. I'm just wondering why some wouldn't work on maps. Cheers Andreas On 03/04/2011, at 3:32 PM, Daniel Janus wrote: > Hi Andreas, > >> (some #{:fred} [:fred :barney]) >> => :fred >> This expected. >> Would one be write to expect >> (some

clojure.core/some expected behaviour

2011-04-02 Thread Andreas Kostler
Hi All, (some #{:fred} [:fred :barney]) => :fred This expected. Would one be write to expect (some #{:fred} {:fred "flinstone" :barney "rubble"}) to return => :fred as well? This is not the case, it return nil What's the (easy) explanation for this? Cheers Andreas -- You received this message b

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-02 Thread Andreas Kostler
Another way to skin the cat: (defn take-by [f coll] (cons (first coll) (for [[x y] (map (fn [x y] [x y]) coll (rest coll)) :while (= (f x) (f y))] x))) Cheers Andreas On 03/04/2011, at 2:21 PM, Ken Wesson wrote: > On S

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-02 Thread Andreas Kostler
Without bugs this time: (defn take-by [f coll] (lazy-seq (when-let [s (seq coll)] (let [x (first s) y (second s)] (if (and x y (= (f x) (f y))) (cons x (take-

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-02 Thread Andreas Kostler
Or more in line with the implementation of take-while: (defn take-by [f coll] (lazy-seq (when-let [s (seq coll)] (let [x (first s) y (second s)] (if (= (f x) (f y))

Re: Can I add the contents of seq to a collection without wrapping?

2011-03-28 Thread Andreas Kostler
Colin, PersistenQueue doesn't have direct Reader support. However: user> (def source-queue (ref clojure.lang.PersistentQueue/EMPTY)) #'user/source-queue user> (for [x (load-sources 1 2 3)] x) (1 2 3) with (defn load-sources [& sources] (dosync (alter source-q

Re: (memoize) and recursive functions (Clojure 1.2)

2011-03-28 Thread Andreas Kostler
Hi Ben, it seems like this has been broken in Clojure 1.2: http://groups.google.com/group/clojure/browse_thread/thread/d7141efd4958a7e5/4d847865a9d5fb8b?lnk=gst&q=memoize+fib#4d847865a9d5fb8b One solution is (def f (memoize fn [n]... will do what you want. Cheers Andreas On 29/03/2011, at 10:47

Re: Can I add the contents of seq to a collection without wrapping?

2011-03-28 Thread Andreas Kostler
Hi Colin, Can you be a bit more specific? The code you posted actually works without vec... On 29/03/2011, at 6:52 AM, colint wrote: > Hi, is there a function to add the contents of seq to a collection > without using vec and into combo? > > (defn load-sources [&sources] > (dosync >(alter

Re: DDJ for Clojure/Lisp/FP

2011-03-21 Thread Andreas Kostler
> 1) A tour of the Java / JVM ecosystem for clojure programmers with little or > no Java background. What are the libraries, frameworks, and tools every > clojure programmer should know about, even if he or she never writes a line > of java? How do we use them from clojure? Actually this mig

Re: Not quite getting for (newb question)

2011-03-20 Thread Andreas Kostler
No worries, always a pleasure :) On 21/03/2011, at 12:43 PM, Brett Morgan wrote: > Ahh, got it. Thank you Andreas. > > On Sun, Mar 20, 2011 at 6:55 PM, Andreas Kostler > wrote: > Hi Brett, > A :while clause continues the evaluation ONLY while it's expression is true &g

Re: Not quite getting for (newb question)

2011-03-20 Thread Andreas Kostler
Hi Brett, A :while clause continues the evaluation ONLY while it's expression is true (for [x (range 10) y (range 10) :while (< x y)] [x y]) will terminate as soon as (< x y) is false. Since (< 0 0) is the first expr to evaluate, evaluation stops right there. What you want is (for [x (range 10

Re: Beginning Clojure

2011-03-20 Thread Andreas Kostler
Hi, Depending on your level of Lisp expertise, I'd suggest digging into Clojure frameworks like Ring or Compojure. You might find the books on Clojure interesting ("Practical Clojure", "Programming Clojure", "The Joy of Clojure", "Clojure in Action"). The latter two are work in progress (however,

Re: Throwing an Exception with get

2011-03-20 Thread Andreas Kostler
Well, get-with-exception attempts to model a restriction on a relation (e.g. select in sql) so I believe a missing key indeed indicates an error. On 21/03/2011, at 9:25 AM, Daniel Werner wrote: > On 20 March 2011 22:02, Andreas Kostler > wrote: >> Would that be flow control though

Re: How to Sum a Sequence?

2011-03-20 Thread Andreas Kostler
>> Do you have any resources or books that help with such things? (Taking >> a problem and solving it the way you did) > > I think, my suggestions are not specific to clojure, but they apply to > any functional language. All of them have functions for filtering > sequences, applying a function t

Re: Throwing an Exception with get

2011-03-20 Thread Andreas Kostler
Would that be flow control though? I see this exception as a rather exceptional circumstance for this application... On 20/03/2011, at 10:53 PM, Daniel Werner wrote: > On Mar 20, 10:50 am, Andreas Kostler > wrote: >> I would like to throw an exception when I'm trying to retr

Re: Throwing an Exception with get

2011-03-20 Thread Andreas Kostler
Hi Ambrose, No java interop. I do a selection based on map keys. Suppose I have a set of maps: (def rel #{{:a "a" :b "b"}{:a "c" :b "d"}{:a "e" :b "f"}}) And I do a select-like query (select rel [[:a :eq "a"]]) => #{{:a "a" :b "b"}} Now, I want to distinguish between a value that doesn't match an

Re: How to Sum a Sequence?

2011-03-20 Thread Andreas Kostler
e book-tipp! I'll be sure to check it out. > All this is intrinsic Clojure behaviour. Clojure is unique in this way. You will find that other flavours of Lisp allow mutable data (e.g. setf in common lisp). Thassilo provided a more idiomatic solution to your problem. Andreas > On Mar

Throwing an Exception with get

2011-03-20 Thread Andreas Kostler
Hi all, I would like to throw an exception when I'm trying to retrieve a value in a map for a key that doesn't exist. The obvious first shot was: (get {:foo "bar"} :foo (throw (new Exception "Oh no!"))) However, this doesn't work because the exception always throws since get apparently eagerly e

Re: How to Sum a Sequence?

2011-03-20 Thread Andreas Kostler
Hi Christian, What you're trying to do is to build up a vector with the last element of the vector being the answer to your problem: (last answer) => 4613732 You're trying to use cons (conj) to build up that list. Now, your function below never terminates because you're: a) Not actually buildin

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Andreas Kostler
27;d need authors, reviewers, people with ideas for content-- > and maybe an administrator/logistics person. Who's interested? > > > Best wishes, > > Gregg Williams > > > On Mar 13, 5:30 pm, Andreas Kostler > wrote: >> Hi there, >> Is there somethi

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Andreas Kostler
uld have to be start up with one topic > (lisp or FP) and if the system worked you could add more topics. > > The length could be like steve yeggy blogposts or like the ibm ähh > articals (http://www.ibm.com/developerworks/java/library/j-clojure- > protocols/). > > On Mar 14, 1

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Andreas Kostler
On 14/03/2011, at 8:00 PM, Saul Hazledine wrote: > On Mar 14, 3:41 am, Andreas Kostler > wrote: >> >> Maybe this group could finally get the ball rolling...Surely a collection of >> highly talented individuals could initiate a forum for >> technical exchan

Re: DDJ for Clojure/Lisp/FP

2011-03-13 Thread Andreas Kostler
> Well, it was announced two or three years ago, but has never actually been > produced, so I wouldn't get your hopes up :) > Maybe this group could finally get the ball rolling...Surely a collection of highly talented individuals could initiate a forum for technical exchange at the level Peter

Re: DDJ for Clojure/Lisp/FP

2011-03-13 Thread Andreas Kostler
On 14/03/2011, at 12:05 PM, Alan Dipert wrote: > Hi Andreas, > >> Is there something like Doctor Dobbs Journal for Clojure/Lisp or even >> functional programming related topics? > > To my knowledge, not yet. Peter Seibel's yet-to-be-published "Code > Quarterly" sounds similar to what you're lo

DDJ for Clojure/Lisp/FP

2011-03-13 Thread Andreas Kostler
Hi there, Is there something like Doctor Dobbs Journal for Clojure/Lisp or even functional programming related topics? - A (peer reviewed) place collecting contributions from developers all over the world working in Clojure/Lisp environments sharing their insights and solutions to problems develo

Re: Macros, macros, macros

2011-03-08 Thread Andreas Kostler
On 09/03/2011, at 4:24 PM, Alan wrote: > On Mar 8, 9:14 pm, Andreas Kostler > wrote: >> Hi Daniel, >> Thanks for your reply. >> On 09/03/2011, at 11:57 AM, Daniel Solano Gomez wrote: >>> On Wed Mar 9 11:16 2011, Andreas Kostler wrote: >>>> Hi all,

Re: Macros, macros, macros

2011-03-08 Thread Andreas Kostler
Hi Daniel, Thanks for your reply. On 09/03/2011, at 11:57 AM, Daniel Solano Gomez wrote: > On Wed Mar 9 11:16 2011, Andreas Kostler wrote: >> Hi all, >> >> I need a macro to basically outputs this: >> >> (macroexpand '(chain-field-queries record "loca

  1   2   >