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

2010-08-09 Thread gary ng
On Sun, Aug 8, 2010 at 10:32 PM, Meikel Brandmeyer m...@kotka.de wrote: I'm bit confused about what you mean here, but vector append (read: conj) is O(1) (don't nail me down on whether it's amortised). There is no array copying going on underneath. Assuming vector is implemented in some form

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

2010-08-09 Thread gary ng
On Sun, Aug 8, 2010 at 10:50 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Aug 8, 6:19 pm, gary ng garyng2...@gmail.com wrote: I wrote a similar version in F# which does have the advantage of handling infinite input or a very long partition in the sense that I can still consume the

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

2010-08-09 Thread limux
The follow is the ring's source, and I am a newbie in Clojure. what the defn of run-jetty looks like this form, what's the meaning of #^Server in the defn and let? Thanks in advance. Limux. (defn #^Server run-jetty Serve the given handler according to the options. Options: :configurator

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 liumengji...@gmail.com 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

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 garyng2...@gmail.com 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

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 johannes.fries...@gmail.com wrote: On Aug 9, 8:25 am, limux liumengji...@gmail.com wrote: what's the meaning of #^Server in the defn and let? (defn

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 liumengji...@gmail.com wrote: I see, heartly thanks, and there is no any words about it in API doc of clojure.org

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

Re: zipping sequences

2010-08-09 Thread Meikel Brandmeyer
Hi, On Aug 9, 12:21 pm, Nicolas Oury nicolas.o...@gmail.com 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

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

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 m...@kotka.de wrote: Hi, On Aug 9, 12:21 pm, Nicolas Oury nicolas.o...@gmail.com wrote: (zip [a1 an] [b1 bn]) = [[a1 b1] . [an bn]] (map vector [a1 ... an] [b1 ... bn]) Sincerely Meikel

Re: slow raw io

2010-08-09 Thread cageface
On Aug 7, 5:43 am, Peter Schuller peter.schul...@infidyne.com 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

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 dnolen.li...@gmail.com wrote: On Sat, Aug 7, 2010 at 4:47 PM, frou m...@frou.org wrote: Searching Google, I see there are

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

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

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...

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

2010-08-09 Thread Chouser
On Mon, Aug 9, 2010 at 10:55 AM, Sunil Nandihalli sunil.nandiha...@gmail.com 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

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

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-

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

2010-08-09 Thread Jarkko Oranen
On Aug 9, 7:54 pm, CuppoJava patrickli_2...@hotmail.com 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.

Re: System calls

2010-08-09 Thread Mike Meyer
On Mon, 9 Aug 2010 09:37:14 -0700 (PDT) Dave david.dreisigme...@gmail.com 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

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 chous...@gmail.com wrote: On Aug 9,

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 jscotthic...@gmail.com I was going to try out a compojure tutorial in Eclipse. It

Re: Generics in PersistentXXX classes

2010-08-09 Thread Krukow
On Aug 4, 5:33 pm, Alex Tkachman alex.tkach...@gmail.com 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

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

Re: Generics in PersistentXXX classes

2010-08-09 Thread Krukow
On Aug 4, 3:51 pm, Matt Fowles matt.fow...@gmail.com 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.

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 %)

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

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 a...@malloys.org 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

Re: drop-while for noobs

2010-08-09 Thread jv-li...@tx.rr.com
On Aug 9, 2:09 pm, Alan a...@malloys.org 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)

Re: leiningen-war

2010-08-09 Thread Saul Hazledine
On Aug 9, 5:08 am, rob r.p.l...@gmail.com 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.  

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 patrickli_2...@hotmail.comwrote: Thanks for the reply Jarkko. That helps quite a lot. I

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

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 a...@malloys.org 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

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?

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

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 carlos.torr...@upr.edu 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,

Re: Please help! Really simple function not working.

2010-08-09 Thread Laurent PETIT
2010/8/10 Carlos Torres carlos.torr...@upr.edu 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

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 carlos.torr...@upr.edu 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))

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 p...@hagelb.org 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

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 p...@hagelb.org wrote: On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres carlos.torr...@upr.edu wrote: (defn count-zeros Returns the numbers of zero in a simple sequence of numbers [list1] (cond (empty? list1) 0 (not (zero?

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

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