Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Laurent PETIT
You version does not work for certain kind of data, (as did mine), see my answer to Meikel for more detail, -- Laurent 2009/4/23 Christophe Grand christo...@cgrand.net: Hi all! (defn mystery-function [pred coll]  (lazy-seq    (when (seq coll)      (let [[run etc] (split-with pred coll)]

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Michael Wood
On Thu, Apr 23, 2009 at 9:44 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Hi Meikel, It seems to me that your version is the only safe one so far, that would succesfully indefinitely return values with this test: (dorun (mystery-function true? :foo (repeat true))) Mine, a new version

Re: cannot use swig native shared libraries

2009-04-23 Thread Antonio, Fabio Di Narzo
Thank you for the suggestion, but doesn't help. Note again that I use it with no problems with plain java: ---file:SwigTest.java--- import swig_test.swig_test; public class SwigTest { public static void main(String[] args) { System.load(System.getProperty(user.dir) +

Re: Enlive tutorial

2009-04-23 Thread Christophe Grand
Christophe Grand a écrit : Hi Adrian! Thanks for this tutorial, I put it on the wiki http://wiki.github.com/cgrand/enlive/getting-started (I fixed two typos: a missing paren and an extraneous colon and I simplified to-li). And I removed the part talking about right since I already merged

Swing Java example to Clojure - Question about better translation

2009-04-23 Thread Dimiter malkia Stanev
Hello, I've started dabbling into Swing Clojure, and for fun decided to translate one of the Sun examples (requires Java SE 1.6 though) It's located here: http://java.sun.com/docs/books/tutorial/uiswing/examples/learn/index.html#CelsiusConverter and the java code here:

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Christophe Grand
*Warning this message contains mutable state and may hurt functional sensibilities.* Ugly hack: (defn my-split-with [pred coll] (let [s (atom coll) p #(when-let [r (pred %)] (swap! s rest) r)] [(take-while p coll) (drop-while pred (lazy-seq @s))])) Now it works ;-) Laurent

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Laurent PETIT
1:2 user= (reduce #(concat %1 (if ( %2 6) [ :foo %2] [%2])) [] '(3 4 5 8 4 2)) (3 4 5 :foo 8 4 2) Not good, the expected result would have been (3 4 5 :foo 8 4 2 :foo) Regards, -- Laurent 2009/4/23 Emeka emekami...@gmail.com: (reduce #(concat %1 (if ( %2 6) [ :foo %2] [%2])) [] '(3 4 5 8 4

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Emeka
Laurent, Sampi question was; Let's say I have a sequence of integers: (def a (3 9 1 5 102 -322 ...)) Is there a function for inserting an object—let's say :foo—after elements that fulfill a certain predicate? Furthermore, I mean inserting :foo after any block of elements that fulfill it:

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Michael Wood
On Thu, Apr 23, 2009 at 2:11 PM, Emeka emekami...@gmail.com wrote: Laurent, Sampi question was; Let's say I have a sequence of integers:  (def a (3 9 1 5 102 -322 ...)) Is there a function for inserting an object—let's say :foo—after elements that fulfill a certain predicate?

Re: ICFP 2009

2009-04-23 Thread Andrew Wagner
Sounds like a fun thing to try. Could someone give a brief description of what would be required in terms of time commitment to participate on a team? (Sadly, spare time is hard to come by...) It's just one weekend. As much or as little time as you can commit to for that weekend.

contrib mercurial mirror is back up

2009-04-23 Thread Shawn Hoover
My bitbucket contrib mirror is public again at http://bitbucket.org/shoover/clojure-contrib-mirror. Thanks to bitbucket for munging unrecognized email addresses per my request. Shawn --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Christophe Grand
Laurent PETIT a écrit : 2009/4/23 Christophe Grand christo...@cgrand.net: *Warning this message contains mutable state and may hurt functional sensibilities.* Ugly hack: (defn my-split-with [pred coll] (let [s (atom coll) p #(when-let [r (pred %)] (swap! s rest) r)]

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Christophe Grand
Laurent PETIT a écrit : I guess you're right. But a little warning in the javadoc could help newcomers not shoot themselves in the foot. And the problem is, calling directly (second) without calling (first) would work most of the time. I wanted to make it fail every time = same behaviour

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Laurent PETIT
2009/4/23 Christophe Grand christo...@cgrand.net: Laurent PETIT a écrit : I guess you're right. But a little warning in the javadoc could help newcomers not shoot themselves in the foot. And the problem is, calling directly (second) without calling (first) would work most of the time. I

Re: ICFP 2009

2009-04-23 Thread Rich Hickey
On Apr 23, 8:59 am, Andrew Wagner wagner.and...@gmail.com wrote: Sounds like a fun thing to try. Could someone give a brief description of what would be required in terms of time commitment to participate on a team? (Sadly, spare time is hard to come by...) It's just one weekend. As

Re: ICFP 2009

2009-04-23 Thread Paul Stadig
On Thu, Apr 23, 2009 at 11:04 AM, Rich Hickey richhic...@gmail.com wrote: On Apr 23, 8:59 am, Andrew Wagner wagner.and...@gmail.com wrote: Sounds like a fun thing to try. Could someone give a brief description of what would be required in terms of time commitment to participate on a

Re: The Path to 1.0

2009-04-23 Thread Laurent PETIT
2009/4/23 Rich Hickey richhic...@gmail.com: On Apr 22, 12:41 pm, Laurent PETIT laurent.pe...@gmail.com wrote: 2009/4/22 Rich Hickey richhic...@gmail.com: [...] {:major 1, :minor 0, :incremental 0, :qualifier :rc1 :interim true} for interim versions and {:major 1, :minor 0,

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Christophe Grand
Laurent PETIT a écrit : 2009/4/23 Christophe Grand christo...@cgrand.net: Laurent PETIT a écrit : I guess you're right. But a little warning in the javadoc could help newcomers not shoot themselves in the foot. And the problem is, calling directly (second) without calling (first)

Re: Simple sequence question: inserting something after blocks of fulfilling elements

2009-04-23 Thread Laurent PETIT
2009/4/23 Christophe Grand christo...@cgrand.net: Laurent PETIT a écrit : 2009/4/23 Christophe Grand christo...@cgrand.net: Laurent PETIT a écrit : I guess you're right. But a little warning in the javadoc could help newcomers not shoot themselves in the foot. And the problem is, calling

Re: best way to compete against meld?

2009-04-23 Thread e
to qualify the simple part, I was saying that I wanted to restrict myself to just calling what's in clojure and clojure-contrib, mostly. simple from my user perspective, since another part of the study could easily include building a data structure on top of what's already in clojure. On Thu,

Re: Enlive tutorial

2009-04-23 Thread Christophe Grand
I updated the tutorial to reflect a new behavior: enlive now precomputes html output for untouched or partly untouched elements. ((template (java.io.StringReader. divuntouched element/divdiv class=foowon't last/div) [] [[:div last-child]] (content new content))) used to return: ( html

Re: Abstract data types in functional languages

2009-04-23 Thread Mark Engelberg
In Clojure, the closest thing to an object (short of implementing a class in Java or using gen-class) is the map. But the more I play around with using maps to implement the kinds of things that objects are used for in other languages, the more I'm feeling that maps don't quite cut it. One

Re: Enlive tutorial

2009-04-23 Thread Adrian Cuthbertson
Nice enhancement! On Thu, Apr 23, 2009 at 6:43 PM, Christophe Grand christo...@cgrand.net wrote: I updated the tutorial to reflect a new behavior: enlive now precomputes html output for untouched or partly untouched elements. ((template (java.io.StringReader. divuntouched element/divdiv

Re: Abstract data types in functional languages

2009-04-23 Thread Konrad Hinsen
On Apr 23, 2009, at 18:59, Mark Engelberg wrote: Konrad has written a library that turns equality into a multimethod. This provides the hooks for altering equality for maps, but there are a lot of questions in my mind about how well this will coexist with other Clojure code and just how

Re: ICFP 2009

2009-04-23 Thread Jason Wolfe
I'm interested, although I'm not sure if I'll be around that weekend. I've done quite well in past TopCoder-style contests (where I've had to use Java); it would be fun to do a competition in Clojure. -Jason --~--~-~--~~~---~--~~ You received this message because

tangent: X10 language

2009-04-23 Thread Stuart Sierra
Possibly of interest: I saw a presentation about IBM's experimental X10 language. (Why they named it after the most annoying ad campaign in the history of the web, I'll never know.) X10 is an extension to Java for concurrency and cluster computing. The basic idea is to make it possible to write

Re: tangent: X10 language

2009-04-23 Thread Rich Hickey
On Apr 23, 2:43 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: Possibly of interest: I saw a presentation about IBM's experimental X10 language. (Why they named it after the most annoying ad campaign in the history of the web, I'll never know.) X10 is an extension to Java for

How to have one lib with source in multiple files

2009-04-23 Thread billh04
I came across the term root lib when I googled on how to have one lib with source in multiple files. But, it appears that this was just discussion. I couldn't find the information I wanted on the main clojure page. Right now I have the two files whale.achi.model.place.clj and

Bit-level operations

2009-04-23 Thread Kevin Van Horn
I'm writing an application that needs fast, high-quality random number generation, so I've been implementing a Mersenne Twister random number generator. I'm finding that bit-twiddling in Clojure can be a bit awkward. Here are some specifics: 1. bit-and, bit-or, and bit-xor only take two

Re: How to have one lib with source in multiple files

2009-04-23 Thread Drew Raines
billh04 wrote: Right now I have the two files whale.achi.model.place.clj and whale.achi.model.placeEvaluation.clj that make up one name space whale.achi.model.place. The first file is the root of the namespace. I think you're confused with how Clojure looks for packages in the filesystem.

Re: How to have one lib with source in multiple files

2009-04-23 Thread billh04
I don't think I explained my need clearly. I try to rephrase it. Suppose I have a source file named place.clj in a directory named whale/achi/model like the following: place.clj (ns whale.achi.model.place) partA partB == What I want to do is to keep the same

Re: Bit-level operations

2009-04-23 Thread Dimiter malkia Stanev
You can make your own macro to do that: (defmacro mo [op args] (reduce (fn [a# b#] (cons op [a# b#])) args)) (mo + 1 2 3 4) (print expanded= (macroexpand '(mo + 1 2 3 4)) \n) ;expanded= (+ (+ (+ 1 2) 3) 4) On Apr 23, 5:57 pm, Kevin Van Horn kvanh...@ksvanhorn.com wrote: I'm writing an

Re: Bit-level operations

2009-04-23 Thread Dimiter malkia Stanev
Here's even more concise version: (defmacro mo [op args] (reduce (fn [ ab#] (cons op ab#)) args)) On Apr 23, 9:23 pm, Dimiter \malkia\ Stanev mal...@gmail.com wrote: You can make your own macro to do that: (defmacro mo [op args]   (reduce (fn [a# b#] (cons op [a# b#])) args)) (mo + 1

Re: How to have one lib with source in multiple files

2009-04-23 Thread Laurent PETIT
Hi, Please note that a convention (but it's really just one convention) could also be to name file for partB : place_partB.clj (or even place_part_b.clj since in clojure camel case notation is not the preferred way to write things, hyphens and lower cases are - but hyphens must be replaces by

Re: How to have one lib with source in multiple files

2009-04-23 Thread Adrian Cuthbertson
billh04, have a look at the compojure project (http://github.com/weavejester/compojure/tree/master). In that James uses an immigrate function which may be useful to you. Also the structure used is a good example of a reasonably large, quite complex project. Hth, Adrian. On Fri, Apr 24, 2009 at