a macro to debug the let form

2010-11-24 Thread Sunil S Nandihalli
Hello everybody, I was trying to learn to write clojure macros and the code is posted here in the following link https://gist.github.com/715047 There are basically three macros 1. with-seperator - a zero argument macro and is supposed to just draw a line to indicate beginning and ending of the ex

Re: every-nth

2010-11-24 Thread Meikel Brandmeyer
Hi, On 25 Nov., 05:06, Sunil S Nandihalli wrote: > (defn every-nth [n coll] >   (letfn [(evn [cn s] >             (when s >               (if (= cn 1) >                 (lazy-seq (cons (first s) (evn n (next s >                 (evn (dec cn) (next s)] >     (evn n coll))) Since you want

Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-24 Thread LauJensen
Hi Brenton, Yes the OFFSET/LIMIT syntax differs from backend to backend. However in some instances (like MySQL/PostgreSQL) they have ensured compatability so that the same statement will run on several DBs although the syntax might not be considered 'native'. For something like Oracle there actual

Re: every-nth

2010-11-24 Thread Stuart Campbell
On 25 November 2010 16:56, Ken Wesson wrote: > Eh. This is weird. It seems that (partition n coll) drops the last > part of coll if it's not a multiple of n in size; e.g. (partition 3 [1 > 2 3 4 5]) yields ((1 2 3)) and not ((1 2 3) (4 5)). (partition n n [] > coll) does do that though. > See al

Re: distinguishing the symbols generated by gensym from those that were part of the code

2010-11-24 Thread Ken Wesson
On Thu, Nov 25, 2010 at 1:06 AM, Sunil S Nandihalli wrote: > Hello everybody, >  Is there a function which can tell me if a particular symbol was generated > by gensym or was present in the code? > Sunil. I don't think so. On the other hand: (def my-gensyms (atom #{})) (defn my-gensym ([]

Re: every-nth

2010-11-24 Thread Sunil S Nandihalli
Thanks everybody, Clojure community is awesome .. and also I just wanted to learn to use lazy-seq that is why it was written in the way I showed you all. Thanks again. Sunil. On Thu, Nov 25, 2010 at 11:26 AM, Ken Wesson wrote: > Eh. This is weird. It seems that (partition n coll) drops the las

distinguishing the symbols generated by gensym from those that were part of the code

2010-11-24 Thread Sunil S Nandihalli
Hello everybody, Is there a function which can tell me if a particular symbol was generated by gensym or was present in the code? Sunil. -- 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 Not

Re: every-nth

2010-11-24 Thread Ken Wesson
Eh. This is weird. It seems that (partition n coll) drops the last part of coll if it's not a multiple of n in size; e.g. (partition 3 [1 2 3 4 5]) yields ((1 2 3)) and not ((1 2 3) (4 5)). (partition n n [] coll) does do that though. OTOH, (mapcat identity (partition 1 n coll)) (apply concat (pa

Re: every-nth

2010-11-24 Thread David Sletten
I stand corrected. I thought it required another arg. Yours was right already. On Nov 24, 2010, at 11:53 PM, David Sletten wrote: > > On Nov 24, 2010, at 11:45 PM, Ken Wesson wrote: > >> On Wed, Nov 24, 2010 at 11:11 PM, Baishampayan Ghose >> wrote: I just needed a function for every-nth

Re: every-nth

2010-11-24 Thread Ken Wesson
On Wed, Nov 24, 2010 at 11:53 PM, David Sletten wrote: > > On Nov 24, 2010, at 11:45 PM, Ken Wesson wrote: > >> On Wed, Nov 24, 2010 at 11:11 PM, Baishampayan Ghose >> wrote:  I just needed a function for every-nth element in a sequence.. I know it can be trivially implemented as .. >>

Re: every-nth

2010-11-24 Thread David Sletten
On Nov 24, 2010, at 11:45 PM, Ken Wesson wrote: > On Wed, Nov 24, 2010 at 11:11 PM, Baishampayan Ghose > wrote: >>> I just needed a function for every-nth element in a sequence.. I know it >>> can be trivially implemented as .. >>> (defn every-nth [n coll] >>> (letfn [(evn [cn s] >>>

Re: every-nth

2010-11-24 Thread Ken Wesson
On Wed, Nov 24, 2010 at 11:11 PM, Baishampayan Ghose wrote: >>  I just needed a function for every-nth element in a sequence.. I know it >> can be trivially implemented as .. >> (defn every-nth [n coll] >>   (letfn [(evn [cn s] >>             (when s >>               (if (= cn 1) >>               

Re: every-nth

2010-11-24 Thread Baishampayan Ghose
>  I just needed a function for every-nth element in a sequence.. I know it > can be trivially implemented as .. > (defn every-nth [n coll] >   (letfn [(evn [cn s] >             (when s >               (if (= cn 1) >                 (lazy-seq (cons (first s) (evn n (next s >                 (ev

every-nth

2010-11-24 Thread Sunil S Nandihalli
Hello everybody, I just needed a function for every-nth element in a sequence.. I know it can be trivially implemented as .. (defn every-nth [n coll] (letfn [(evn [cn s] (when s (if (= cn 1) (lazy-seq (cons (first s) (evn n (next s (

Re: discussing Clojure with non-CS types

2010-11-24 Thread CuppoJava
I must admit that even though I love Clojure and use it daily for many things, I don't like using it very much for my research (machine learning) which involves a lot of number crunching. The main reasons being: Numerical software involves a lot of array indexing, and loops, and not much else. Cl

Re: sort-by reverse order?

2010-11-24 Thread Alex Baranosky
Very nice On Tue, Nov 23, 2010 at 4:03 PM, Tyler Perkins wrote: > Nice! And with just a bit more, we have a clean, sorting DSL: > > (def asc compare) > (def desc #(compare %2 %1)) > ;; compare-by generates a Comparator: > (defn compare-by [& key-cmp-pairs] > (fn [x y] > (loop [[k cmp & mor

Re: appengine-magic 0.3.0: Clojure on Google App Engine

2010-11-24 Thread Vesa Marttila
On Nov 24, 7:58 pm, Constantine Vetoshev wrote: > You can't directly use datastore functions from the REPL. When I said > "interactive development through the REPL", I meant the ability to > recompile individual files and functions inside a running application > — this definitely works across the

Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-24 Thread Brenton
> ClojureQL does not take the backend in to account. This is the one > feature from the old CQL that I didn't want to carry over because it > would be impossible for me to cater to all backends. If you hit > specific problems, let me know and I'll see what we can do. > > We adhere to SQL92 and test

Re: Question about an idiom.....

2010-11-24 Thread Laurent PETIT
2010/11/24 Mike Meyer > On Wed, 24 Nov 2010 22:51:09 +0100 > Daniel Werner wrote: > > > On 24 November 2010 21:40, Mike Meyer > > wrote: > > > Could someone explain where this urge to write (-> expr (func arg)) > > > instead of (func expr arg) comes from? > > > > I like to use -> and ->> becaus

Re: Question about an idiom.....

2010-11-24 Thread Mike Meyer
On Wed, 24 Nov 2010 22:51:09 +0100 Daniel Werner wrote: > On 24 November 2010 21:40, Mike Meyer > wrote: > > Could someone explain where this urge to write (-> expr (func arg)) > > instead of (func expr arg) comes from? > > I like to use -> and ->> because they allow me to add more steps to > t

Re: Question about an idiom.....

2010-11-24 Thread Daniel Werner
On 24 November 2010 21:40, Mike Meyer wrote: > Could someone explain where this urge to write (-> expr (func arg)) > instead of (func expr arg) comes from? I like to use -> and ->> because they allow me to add more steps to the "pipeline" as needed, without requiring ever more deeply nested paren

Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-24 Thread LauJensen
No problem Luke. ClojureQL does not take the backend in to account. This is the one feature from the old CQL that I didn't want to carry over because it would be impossible for me to cater to all backends. If you hit specific problems, let me know and I'll see what we can do. We adhere to SQL92 a

ANN: Durable Clojure - Functions and Closures

2010-11-24 Thread Alyssa Kwan
Extension of http://groups.google.com/group/clojure/browse_thread/thread/7c917e983f345723/a7ee771a7bcaaefc Hi everyone! I've extended the Clojure core to extend durability to functions and closures. 1. Functions with lexical and dynamic bindings are now supported. This includes functions that g

Re: Question about an idiom.....

2010-11-24 Thread Laurent PETIT
2010/11/24 Mike Meyer > On Wed, 24 Nov 2010 00:37:07 -0800 (PST) > LauJensen wrote: > > You just touched on an idiom I see fairly often here that bugs me. I'm > not intentionally singling you - or CQL! - out for this, but you made > a comment that sets up my question perfectly. > > > (let [photo

Question about an idiom.....

2010-11-24 Thread Mike Meyer
On Wed, 24 Nov 2010 00:37:07 -0800 (PST) LauJensen wrote: You just touched on an idiom I see fairly often here that bugs me. I'm not intentionally singling you - or CQL! - out for this, but you made a comment that sets up my question perfectly. > (let [photo-counts (-> (table :photos) >

Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-24 Thread Luke VanderHart
Thanks... I think I do see the benefit. I'll certainly give it a try and see if I can get the feel of it. One question... You say it generates optimized SQL. Does it take the DBMS into account? I know the performance profiles of various SQL idioms vary widely between MySQL and Oracle, for example

Re: discussing Clojure with non-CS types

2010-11-24 Thread Mike Meyer
On Wed, 24 Nov 2010 09:20:49 -0800 (PST) cej38 wrote: > I am a physicist. I have been using Clojure full time for the last > year and a half. The reasons that Rich (and most other Clojure > evangelists) give for using Clojure, are all nice and good, but they > point to what computer scientists

Re: memcache, redis connection pooling

2010-11-24 Thread Wilson MacGyver
I highly recommend jedis for redis java lib. It supports connection pooling, pub/sub. and works with the 2.0 protocol. https://github.com/xetorthio/jedis Any reason why you want to use both memcached and redis at the same time? redis is basically memcached++, with collection/queue support as valu

Re: record serialization

2010-11-24 Thread Alex Miller
That was me and I blogged it for good measure ( http://tech.puredanger.com/2010/11/23/implementing-java-interfaces-with-clojure-records/ ) and added the example to clojure docs ( http://clojuredocs.org/clojure_core/clojure.core/defrecord#example_550 ). On Nov 24, 6:10 am, Islon Scherer wrote: > T

Re: *warn-on-reflection* broken in 1.2?

2010-11-24 Thread Ken Wesson
On Wed, Nov 24, 2010 at 11:18 AM, Sergey Didenko wrote: > Here is the Enclojure ticket - > https://www.assembla.com/spaces/enclojure/tickets/83-rebinding-of-vars-does-not-work-in-ide-repl--e-g--*print-meta*--*warn-on-reflection* It seems to me that *warn-on-reflection* is working, but the reflect

Re: IDE and editors for Clojure

2010-11-24 Thread Ken Wesson
On Wed, Nov 24, 2010 at 1:33 PM, Sergey Didenko wrote: > I use Enclojure. > > It works quite well though has some bugs. For example *warn-on-reflection* > can not be set from its REPL. I use a standalone REPL for this case. Actually it can be set. There seems to be a bug in 1.4.0 with buffering.

Re: Porting libraries to ClojureCLR

2010-11-24 Thread Ken Wesson
I gave some thought to the Integer vs. Int32 issue. I think what would help here is a way to alias classes when :importing them. It would require tweaking the ns macro and possibly parts of the runtime. The outcome would be to allow something like (ns foo (:import (java.util.concurrent

Re: discussing Clojure with non-CS types

2010-11-24 Thread cej38
Another thought: 9. Unit testing is much easier! The effort it takes to write unit tests is Fortran is so high, it might as well be impossible, and thus almost no one does it. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, se

Re: Is clojure.core/syntax-quote gone from clojure-1.2?

2010-11-24 Thread Ken Wesson
+1 -- 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 unsubscribe from this group, send email to cl

Re: discussing Clojure with non-CS types

2010-11-24 Thread cej38
Having a fast code is important, but as I have often said to colleagues, computer time is cheap, my time is not. If I can write code that does the same thing in two languages, and the code written in one language runs in half the time of the other, while the code in the other language took half th

Re: IDE and editors for Clojure

2010-11-24 Thread Sergey Didenko
I use Enclojure. It works quite well though has some bugs. For example *warn-on-reflection* can not be set from its REPL. I use a standalone REPL for this case. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cloj

Re: discussing Clojure with non-CS types

2010-11-24 Thread Eric Lavigne
> I am a physicist.  I have been using Clojure full time for the last > year and a half.  The reasons that Rich (and most other Clojure > evangelists) give for using Clojure, are all nice and good, but they > point to what computer scientists think about.  If you want scientists > and engineers to

Re: discussing Clojure with non-CS types

2010-11-24 Thread cej38
yes On Nov 24, 12:28 pm, Joop Kiefte wrote: > 2010/11/24 cej38 : > > > > > > > 5. ease of changing function calls to allow for extra stuff/ > > functionality without breaking other stuff.  An example would be best > > here.  Suppose I had defined some function that worked for a specific > > purpo

Re: appengine-magic 0.3.0: Clojure on Google App Engine

2010-11-24 Thread Constantine Vetoshev
On Nov 24, 6:41 am, Vesa Marttila wrote: > I have a question about this release: I understood from this release > announcement that entities can be saved from the REPL, but I was not > able to do so and the official documentation still states that it > can't be > done, which is the case? You can'

Re: discussing Clojure with non-CS types

2010-11-24 Thread Joop Kiefte
2010/11/24 cej38 : > 5. ease of changing function calls to allow for extra stuff/ > functionality without breaking other stuff.  An example would be best > here.  Suppose I had defined some function that worked for a specific > purpose: > > (defn setzero [value] >  "If value is less than 1.0E-8 set

discussing Clojure with non-CS types

2010-11-24 Thread cej38
I am a physicist. I have been using Clojure full time for the last year and a half. The reasons that Rich (and most other Clojure evangelists) give for using Clojure, are all nice and good, but they point to what computer scientists think about. If you want scientists and engineers to think abou

Re: priority queue for scheduling events in the future

2010-11-24 Thread Mark Engelberg
Thanks! On Wed, Nov 24, 2010 at 8:30 AM, Tom Faulhaber wrote: > OK, I'm doing stuff there now. > > I'll move the comment to the ns doc string, then. > > There are still issues with autodoc and protocols/types, but priority > queues look like they'll be a good sandbox for resolving them. > > Tom >

Re: priority queue for scheduling events in the future

2010-11-24 Thread Tom Faulhaber
OK, I'm doing stuff there now. I'll move the comment to the ns doc string, then. There are still issues with autodoc and protocols/types, but priority queues look like they'll be a good sandbox for resolving them. Tom On Nov 24, 2:51 am, Mark Engelberg wrote: > No reason other than my lack of

Re: *warn-on-reflection* broken in 1.2?

2010-11-24 Thread Sergey Didenko
Here is the Enclojure ticket - https://www.assembla.com/spaces/enclojure/tickets/83-rebinding-of-vars-does-not-work-in-ide-repl--e-g--*print-meta*--*warn-on-reflection* > On 4 November 2010 15:11, Ken Wesson wrote: > >> The website has this example: >> >> (set! *warn-on-reflection* true) >> -> t

Re: ANN: Gloss, a byte-format DSL

2010-11-24 Thread Zach Tellman
ByteBuffers have an order() method which allows you to toggle the endianness. I haven't tested this, but since everything is built on top of Java's ByteBuffer functionality it should be fine as long as the ByteBuffers are correctly set and correctly ordered with respect to each other. Zach On No

Re: ANN: Gloss, a byte-format DSL

2010-11-24 Thread Zach Tellman
On Nov 24, 12:42 am, Michael Wood wrote: > Hi > > On 24 November 2010 04:43, Zach Tellman wrote: > > > There are a couple of different things being discussed here.  I don't > > think there's any harm in allowing maps as frames, as long as people > > understand that they're arbitrarily ordered (al

Re: Porting libraries to ClojureCLR

2010-11-24 Thread nickik
I thought about that a little too. The thing is that clojure is doing something almost imposible. There is almost know way around writing you json library backand in clr interop. If we want to make clojure programm that run on the clr, the jvm and possibly in the browser we have to write pure cloj

Clojure / OpenJDK / fork join (etc.) at FOSDEM

2010-11-24 Thread Tom Marble
All: Join us at FOSDEM 2011 to be part of our sessions where we'll discuss the state of Free Java! This is the PERFECT place to talk about cool things going on with Clojure such as taking advantage of JDK 7 or JDK 8 features *today* through OpenJDK trunk. Typically this conference has brought tog

Re: appengine-magic 0.3.0: Clojure on Google App Engine

2010-11-24 Thread Vesa Marttila
On Nov 23, 6:55 pm, Constantine Vetoshev wrote: > appengine-magic abstracts away nearly all the boilerplate necessary to > deploy an App Engine application. It also enables interactive > development through the REPL. The new version has full support for > many App Engine services: the datastore, m

Re: ANN: Gloss, a byte-format DSL

2010-11-24 Thread zoka
JVM stores numbers in in big endian format - is there a way to process binary stream containing little endian numbers? Zoka On Nov 24, 7:24 am, Zach Tellman wrote: > Good question.  The solution didn't make the cut for my initial > release, but will be added soon.  My plan is to have an (ordered

Re: Porting libraries to ClojureCLR

2010-11-24 Thread David Jagoe
On 24 November 2010 02:11, JMatt wrote: > The easiest way to prevent divergence is to write and use native > clojure libraries. I totally agree. However because of clojure's excellent interop capabilities it is extremely common (in fact encouraged) for developers to directly use Java code. For ex

Re: record serialization

2010-11-24 Thread Islon Scherer
Thanks for the answers! Some guy told me on irc that you can implement interfaces right in the record definition like (defrecord R [a b] SomeInterface (methods...)) Regards. Islon On Nov 24, 4:25 am, Shantanu Kumar wrote: > Shantanu Kumar wrote: > > Islon Scherer wrote: > > > Yes, java serializa

Re: priority queue for scheduling events in the future

2010-11-24 Thread Mark Engelberg
No reason other than my lack of knowledge that ns doc strings are picked up by autodoc and comments are not. :) On Wed, Nov 24, 2010 at 12:36 AM, Tom Faulhaber wrote: > Mark, > > Is there a reason that you put the documentation in a comment rather > than as the ns doc string so that autodoc would

Re: (into my_vec) of order O(n)

2010-11-24 Thread Meikel Brandmeyer
Hi, On 24 Nov., 11:35, Andreas Kostler wrote: > Where's the flaw in my thinking there? This is what (concat ...) does. However, a vector promises O(log32 N) random access, which you can't if you don't add elements of the second argument into the vector structure. Then you can only promis O(n) f

(into my_vec) of order O(n)

2010-11-24 Thread Andreas Kostler
Can someone please explain why an insert into a vector: (insert my_vec [:a :b :c] (range 10)) would be of linear time complexity based on the size of the second argument? I would have thought that this would boil down to something like adding a reference to the first element of the sequence returne

Is clojure.core/syntax-quote gone from clojure-1.2?

2010-11-24 Thread Rock
I was looking for it, but to no avail! Anyway, something I was wondering about. Why don't we take the best from all possible worlds? In this case, Clojure and Scheme (R6RS). It would be nice to have syntax-quote, unquote, and unquote-splicing as true macros (or special forms), and keep `, ~, and ~

a simple .. macro for debugging code inside ->>

2010-11-24 Thread Sunil S Nandihalli
Hello everybody, I just wrote a simple macro for debugging the ->> .. just thought of sharing it with you all (defmacro print-and-return ([x] `(let [x# ~x] (println x#) x#)) ([flag x] `(let [flag# '~flag x# ~x] (println flag#) (println x#)

Re: priority queue for scheduling events in the future

2010-11-24 Thread Rasmus Svensson
2010/11/24 HiHeelHottie : > > 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. I would a

Re: ANN: Gloss, a byte-format DSL

2010-11-24 Thread Michael Wood
Hi On 24 November 2010 04:43, Zach Tellman wrote: > There are a couple of different things being discussed here.  I don't > think there's any harm in allowing maps as frames, as long as people > understand that they're arbitrarily ordered (alphabetically by key, > but that's an implementation det

Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-24 Thread LauJensen
Hi Luke, Thanks! Initially CQL0.1 was motivated by "everything in Clojure" which was the driving design principle behind the first version of CQL. When I scrapped that project (for reasons you can read on my blog) I instead turned my attention towards Relational Algebra as this gives you unique w

Re: priority queue for scheduling events in the future

2010-11-24 Thread Tom Faulhaber
Mark, Is there a reason that you put the documentation in a comment rather than as the ns doc string so that autodoc would pick it up? Currently, priority queues are undiscoverable by autodoc users. Tom On Nov 23, 9:41 pm, Mark Engelberg wrote: > In 1.3, you can use clojure.contrib.priority-map