Re: why the def of run-jetty looks like "defn #^Server run-jetty"

2010-08-09 Thread j-g-faustus
On Aug 9, 8:25 am, limux wrote: > what's the meaning of > #^Server in the defn and let? > (defn #^Server run-jetty ... >   (let [#^Server s (create-server (dissoc options :configurator))] It's a type hint. In the defn it specifies the type of the return value, in the let it gives the type of the

Re: looking for a simpler implementation of a function I'm using

2010-08-09 Thread Meikel Brandmeyer
Hi, On Aug 9, 8:06 am, gary ng wrote: > Assuming vector is implemented in some form of array(well it seems to > have the characteristic of an array where accessing any element would > be O(1)), appending one element can be O(1) if there are space > reserved for some extra items but if that actio

Re: why the def of run-jetty looks like "defn #^Server run-jetty"

2010-08-09 Thread limux
I see, heartly thanks, and there is no any words about it in API doc of clojure.org yet! Regards limux. On 8月9日, 下午3时04分, j-g-faustus wrote: > On Aug 9, 8:25 am, limux wrote: > > > what's the meaning of > > #^Server in the defn and let? > > (defn #^Server run-jetty > ... > > (let [#^Server s

Re: why the def of run-jetty looks like "defn #^Server run-jetty"

2010-08-09 Thread limux
The type hint can be placed on function parameters, let-bound names, var names, and expressions. And it can be placed behind or ahead of them. Isn't it? On 8月9日, 下午3时31分, limux wrote: > I see, heartly thanks, and there is no any words about it in API doc > of clojure.org yet! > > Regards > limux

Re: why the def of run-jetty looks like "defn #^Server run-jetty"

2010-08-09 Thread Nicolas Oury
I am not 100% sure, but it seems they are always ahead. (defn ^Bar foo ...) tells that function foo returns something of class Bar. (f ^Bar expr) says that expr is of type Bar. (let [ ^Bar e expr] ... says that e is of type Bar. (Bar can be a class or an interface.) The main usage (at least

Re: slow raw io

2010-08-09 Thread David Powell
On Sat 07/08/10 14:02 , "Stuart Halloway" stuart.hallo...@gmail.com sent: > No. We want to collect more information and do more comparisons before > moving away from the recommended Java buffering. > Stu This isn't an issue with the buffering, it is an issue with the massive overhead of doing

zipping sequences

2010-08-09 Thread Nicolas Oury
Dear all, I can't find a function in the library and don't see any easy way to write it. I am looking for something like (zip & seqs) such that (zip [a1 an] [b1 bn]) = [[a1 b1] . [an bn]] Any function like that or easy way to construct it? Best regards, Nicolas. -- You receive

Re: zipping sequences

2010-08-09 Thread Meikel Brandmeyer
Hi, On Aug 9, 12:21 pm, Nicolas Oury wrote: > (zip [a1 an] [b1 bn]) = [[a1 b1] . [an bn]] (map vector [a1 ... an] [b1 ... bn]) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Re: slow raw io

2010-08-09 Thread David Powell
> This isn't an issue with the buffering, it is an issue with the massive > overhead of doing character at a time i/o - it is something that you really > should never ever do. I'd say something somewhere doing character at a > time i/o is probably the number one cause of crippling performance pr

Re: zipping sequences

2010-08-09 Thread Nicolas Oury
Thank you very much, it works great. On Mon, Aug 9, 2010 at 11:23 AM, Meikel Brandmeyer wrote: > Hi, > > On Aug 9, 12:21 pm, Nicolas Oury wrote: > >> (zip [a1 an] [b1 bn]) = [[a1 b1] . [an bn]] > > (map vector [a1 ... an] [b1 ... bn]) > > Sincerely > Meikel > > -- > You received th

Re: slow raw io

2010-08-09 Thread cageface
On Aug 7, 5:43 am, Peter Schuller wrote: > Interesting. Why do you consider it recommended to read one character > at a time in a case like this? Maybe there is such a recommendation > that I don't know about, but in general I would consider it contrary > to expected practice when doing I/O if per

Re: TextMate users, what bundle are you using?

2010-08-09 Thread frou
David - Thanks for the tip. I look forward to your REPL interaction; I think this is important for TextMate users to have a good time. On Aug 7, 11:38 pm, David Nolen wrote: > On Sat, Aug 7, 2010 at 4:47 PM, frou wrote: > > Searching Google, I see there are several TextMate bundles for Clojure

Re: slow raw io

2010-08-09 Thread David Powell
> Maybe this seems like a low-priority issue but I think slurp is likely > to be very commonly used. For instance, the Riak tutorial just posted > to Hacker News uses it: > http://mmcgrana.github.com/2010/08/riak-clojure.html In the past I've steered clear of using slurp because it didn't hand ch

ANN : random-hash-tries SNAPSHOT

2010-08-09 Thread Nicolas Oury
Dear all, I have made a very small library, which is very preliminary but usable. It allows to create a distribution and draw from it. Insertions, deletions, drawing are in O(log n). example: (def dist (distribution-from-seqable {:a 1 :b 2})) (draw dist) => :a with proba 1/3, :b with proba 2/

jna Java Native Acess and clojure ....

2010-08-09 Thread Sunil Nandihalli
Hello everybody, I have been trying to use the native libraries in clojure. I have found clj-native and clojure-jna which may serve the purposes. I would like to get a feed back from the community .. Which of these is good to use .. Or do you have any other suggestions.. Thanks in advances... Suni

Re: jna Java Native Acess and clojure ....

2010-08-09 Thread Chouser
On Mon, Aug 9, 2010 at 10:55 AM, Sunil Nandihalli wrote: > Hello everybody, >  I have been trying to use the native libraries in clojure. I have > found clj-native and clojure-jna which may serve the purposes. I would > like to get a feed back from the community .. Which of these is good > to use

Re: System calls

2010-08-09 Thread Dave
Thanks jf, that worked: (ns msms (:gen-class) (:use [clojure.contrib.shell-out :only (sh)])) (defn get-msms-pts-OSX [{pdb-file :pdb-file density :density radius :radius :as all :or {density "1.0" radius "1.5"}}] (if (contains? all :pdb-file) (sh "bash" :in (str "/Users/daviddreisigmey

Basic Lisp Compiler: How to tell which functions to compile?

2010-08-09 Thread CuppoJava
Hello everyone, Just for educational purposes, I'm writing a simple lisp compiler and am stuck on a small problem. I'm trying to write a function called (compile-function), which will take a function as input and compile it. If that function calls other functions, I would like (compile- function)

Re: Basic Lisp Compiler: How to tell which functions to compile?

2010-08-09 Thread Jarkko Oranen
On Aug 9, 7:54 pm, CuppoJava wrote: > Hello everyone, > Just for educational purposes, I'm writing a simple lisp compiler and > am stuck on a small problem. > > I'm trying to write a function called (compile-function), which will > take a function as input and compile it. > > If that function ca

Re: System calls

2010-08-09 Thread Mike Meyer
On Mon, 9 Aug 2010 09:37:14 -0700 (PDT) Dave wrote: > Thanks jf, that worked: > > (ns msms > (:gen-class) > (:use [clojure.contrib.shell-out :only (sh)])) > > (defn get-msms-pts-OSX > [{pdb-file :pdb-file density :density radius :radius :as all :or > {density "1.0" radius "1.5"}}] > (if

Re: Basic Lisp Compiler: How to tell which functions to compile?

2010-08-09 Thread CuppoJava
Thanks for the reply Jarkko. That helps quite a lot. I have some hacks in place that works most of the time, but was stuck trying to figure out a general solution. Knowing that there isn't one puts my mind at ease. -Patrick On Aug 9, 1:56 pm, Jarkko Oranen wrote: > On Aug 9, 7:54 pm, CuppoJava

Eclipse and Compojure

2010-08-09 Thread scott
I was going to try out a compojure tutorial in Eclipse. It appears that only .clj files and not the .class files are included in the compojure jar file. I'm seeing the following error: java.io.FileNotFoundException: Could not locate compojure/ core__init.class or compojure/core.clj on classpath:

Re: Eclipse and Compojure

2010-08-09 Thread Laurent PETIT
Hi, How could I help you from the Eclipse side ? I don't totally understand the steps you're following in Eclipse / counterclockwise (but maybe it's not an eclipse / counterclockwise problem ?) 2010/8/9 scott > I was going to try out a compojure tutorial in Eclipse. It appears > that only .clj

Re: Generics in PersistentXXX classes

2010-08-09 Thread Krukow
On Aug 4, 5:33 pm, Alex Tkachman wrote: > Guys, > > Thanks fo reference. I am still be curious if it should be done > directly in Clojure runtime and available if clojure.jar is in > classpath > Hello Alex, You can easily use clojure.jar but there are a number of disadvantages when all you use

drop-while for noobs

2010-08-09 Thread Alan
Hi all, I'm new to the group; I have some experience with both CL and Java, though it's been a while for each. Anyway I really like Clojure as a way of combining the best parts of the two languages, but I'm still getting the hang of it and there are often things that confuse me. For example, I wan

Re: Generics in PersistentXXX classes

2010-08-09 Thread Krukow
On Aug 4, 3:51 pm, Matt Fowles wrote: > Alex~ > > There is a project on github that does exactly this. > > http://github.com/krukow/clj-ds > > I don't know much about the current state of it, but I have plans in the > next month or so to try it out at work. > > Ma

Re: drop-while for noobs

2010-08-09 Thread Wilson MacGyver
you can do this using partition. let's assume I first define a user=> (def a [:w :n :e :s]) #'user/a user=> (partition 2 1 (conj a (first a))) ((:w :n) (:n :e) (:e :s) (:s :w)) gives you the pairs you need. then you just need to turn it into hash-map by doing (map #(apply hash-map %) (partit

Re: Bug: contains? doesn't work on transient maps or sets

2010-08-09 Thread Nicolas Oury
Does someone know if there is a ticket open for this already? Best, Nicolas. -- 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 pat

Re: Eclipse and Compojure

2010-08-09 Thread scott
I have the tutorial described below working, using Emacs and Leiningen. http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html I created a new Clojure project in Eclipse. I created a "lib" directory, imported the dependent jar files that Leiningen pulled from a repo into

Re: drop-while for noobs

2010-08-09 Thread Armando Blancas
It works with booleans: user=> (drop-while neg? [-3 -2 -1 0 1 2 3 ]) (0 1 2 3) user=> (class (neg? -5)) java.lang.Boolean On Aug 9, 12:09 pm, Alan wrote: > Hi all, I'm new to the group; I have some experience with both CL and > Java, though it's been a while for each. Anyway I really like Clojur

Re: drop-while for noobs

2010-08-09 Thread jv-li...@tx.rr.com
On Aug 9, 2:09 pm, Alan wrote: > Hi all, I'm new to the group Welcome! > I wanted to define a ring function, which takes as input > N objects, and returns a hash table mapping object N to object N+1 > (mod N). I intended to use this to describe a compass object: > (ring :w :n :e :s) should resul

Re: leiningen-war

2010-08-09 Thread Saul Hazledine
On Aug 9, 5:08 am, rob wrote: > As far as I can tell, based on using it so far, the war plugin for > leiningen requires writing a web.xml file.  I was just wondering why > it doesn't generate that xml file for you based on the information > you've specified already in leiningen.  Would that be a g

Re: Basic Lisp Compiler: How to tell which functions to compile?

2010-08-09 Thread Daniel Gagnon
As far as I know, the book "Lisp In Small Pieces" should be a tremendous help for anyone who builds a Lisp interpreter or compiler. You might want to check it out. On Mon, Aug 9, 2010 at 2:21 PM, CuppoJava wrote: > Thanks for the reply Jarkko. That helps quite a lot. I have some hacks > in place

Re: Basic Lisp Compiler: How to tell which functions to compile?

2010-08-09 Thread Jules
It is impossible (undecidable) to tell precisely which functions a function will call. Therefore you will need to consider not exactly set of functions that a function will call, but some superset of that. Why not take as your superset all functions? That is, always compile all functions. On Aug 9

Re: drop-while for noobs

2010-08-09 Thread Alan
Also sorry the indentation is so awful. How do I get Google to let me compose/edit in a fixed-width font? On Aug 9, 12:09 pm, Alan wrote: > Hi all, I'm new to the group; I have some experience with both CL and > Java, though it's been a while for each. Anyway I really like Clojure > as a way of c

Re: drop-while for noobs

2010-08-09 Thread Alan
Weird. I wonder if I was using an outdated version of Clojure or (more likely) assumed from (doc drop-while) that it wouldn't handle false the way I wanted. When doc says "not nil" should I assume it means "neither nil nor false", or should the doc for drop-while be updated? user=> (doc drop-while

Please help! Really simple function not working.

2010-08-09 Thread Carlos Torres
Hi to everyone, I'm trying to create a function that takes a simple list and returns the number of zeros in the list. So I'm assuming that they will enter a list containing only numbers. This is what I have so far, but it only works when the list empty. Can somebody tell me what I'm missing? (def

Re: Please help! Really simple function not working.

2010-08-09 Thread Michael Gardner
On Aug 9, 2010, at 7:24 PM, Carlos Torres wrote: > I'm trying to create a function that takes a simple list and returns the > number of zeros in the list. user=> (count (filter zero? [0 1 2 3 0 4 5 6 0 7 8 9])) 3 -- You received this message because you are subscribed to the Google Groups "Clo

Re: Please help! Really simple function not working.

2010-08-09 Thread gary ng
On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres wrote: > Hi to everyone, > I'm trying to create a function that takes a simple list and returns the > number of zeros in the list. > So I'm assuming that they will enter a list containing only numbers. > This is what I have so far, but it only works wh

Re: Please help! Really simple function not working.

2010-08-09 Thread Laurent PETIT
2010/8/10 Carlos Torres > Hi to everyone, > > I'm trying to create a function that takes a simple list and returns the > number of zeros in the list. > So I'm assuming that they will enter a list containing only numbers. > This is what I have so far, but it only works when the list empty. Can > s

Re: Please help! Really simple function not working.

2010-08-09 Thread Phil Hagelberg
On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres wrote: > (defn count-zeros >   "Returns the numbers of zero in a simple sequence of numbers" >   [list1] >   (cond >     (empty? list1) 0 >     (not (zero? (first list1))) 0 >     :else >     (recur (+ 1 (count-zeros (rest list1)) Michael's soluti

Re: Please help! Really simple function not working.

2010-08-09 Thread Mark Engelberg
On Mon, Aug 9, 2010 at 6:00 PM, Phil Hagelberg wrote: > Just remove the call to recur and it will work, albeit only for lists > small enough to not blow the stack. I'm assuming from the tone of the original post that the author is trying to generally understand how to write recursive functions in

Re: Please help! Really simple function not working.

2010-08-09 Thread Carlos Torres
On Mon, Aug 9, 2010 at 9:00 PM, Phil Hagelberg wrote: > On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres > wrote: > > (defn count-zeros > > "Returns the numbers of zero in a simple sequence of numbers" > > [list1] > > (cond > > (empty? list1) 0 > > (not (zero? (first list1))) 0 > >

Re: drop-while for noobs

2010-08-09 Thread Armando Blancas
> When doc says "not nil" should I assume it means > "neither nil nor false" Nope, false won't be taken as nil; in boolean expressions nil evaluates to false. drop-while's doc mentions only nil but since it's the predicate's return value it should be clear enough, I think. -- You received this m

Re: Running on .Net

2010-08-09 Thread eyeris
I was able to build ClojureCLR using the DLR 1.0 source and the latest clojure-clr in VS 2010. I am able to run Clojure.Main.exe and Clojure.Compile.exe. Is there a way to integrate these into VS, so that I can add .clj files to a project and set the build action to "Build" or "Build with Clojure.C

Re: Please help! Really simple function not working.

2010-08-09 Thread David Sletten
Carlos, I think this is pretty much what you had in mind: (defn count-zeros [l] (cond (empty? l) 0 (zero? (first l)) (inc (count-zeros (rest l))) :else (count-zeros (rest l (count-zeros '(9 8 6 0 1 2 0 5)) => 2 (count-zeros '(9 8 6)) => 0 (count-zeros '()) => 0 Of course th

Re: Please help! Really simple function not working.

2010-08-09 Thread Laurent PETIT
Hi, 2010/8/10 David Sletten > Carlos, > > I think this is pretty much what you had in mind: > (defn count-zeros [l] > (cond (empty? l) 0 > (zero? (first l)) (inc (count-zeros (rest l))) > :else (count-zeros (rest l > > (count-zeros '(9 8 6 0 1 2 0 5)) => 2 > (count-zeros '(

Re: Please help! Really simple function not working.

2010-08-09 Thread David Sletten
On Aug 10, 2010, at 2:22 AM, Laurent PETIT wrote: > > > You could accomplish pretty much the same thing by defining two versions with > different arities: > (defn count-zeros > ([l] (count-zeros l 0)) > ([l result] > (cond (empty? l) result >(zero? (first l)) (recur (rest

Re: Please help! Really simple function not working.

2010-08-09 Thread Laurent PETIT
2010/8/10 David Sletten > > On Aug 10, 2010, at 2:22 AM, Laurent PETIT wrote: > > > >> You could accomplish pretty much the same thing by defining two versions >> with different arities: >> (defn count-zeros >> ([l] (count-zeros l 0)) >> ([l result] >> (cond (empty? l) result >>