macro issue

2009-05-20 Thread Per
a.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol (NO_SOURCE_FILE:8) What do I do wrong here? Per --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: macro issue

2009-05-20 Thread Per
Thanks, that makes a lot of sense! Per On May 20, 10:36 am, Chouser wrote: > On Wed, May 20, 2009 at 9:59 AM, Michael Reid wrote: > > > On Wed, May 20, 2009 at 8:44 AM, pmf wrote: > > >> On May 20, 4:47 am, Per wrote: > >>> ;; The macro &

Re: macro issue

2009-05-20 Thread Per
mbol: :name in this context (NO_SOURCE_FILE:4) Per On May 20, 7:59 am, Michael Reid wrote: > On Wed, May 20, 2009 at 8:44 AM, pmf wrote: > > > On May 20, 4:47 am, Per wrote: > >> ;; The macro > >> (defmacro def-fields [name  tgs] > >>  

Re: benchmarks on a poor-man's matrix concept

2010-03-09 Thread Per Vognsen
entries by whatever means (e.g. calls to user-provided functions in the case of mapping), and return that. Everything is purely functional from the exterior. -Per On Tue, Mar 9, 2010 at 2:57 AM, Jonathan Shore wrote: > Hi, > I'm still trying to work out the best way to deal with opera

Re: benchmarks on a poor-man's matrix concept

2010-03-09 Thread Per Vognsen
By the way, I also noticed your logic is wrong. It should be (+ (* i ncol) j) rather than (* i j). -Per On Tue, Mar 9, 2010 at 2:57 AM, Jonathan Shore wrote: > Hi, > I'm still trying to work out the best way to deal with operations on > heterogenous data in clojure.   I

Re: What's an idiomatic translation of this CL data structure?

2010-03-10 Thread Per Vognsen
e thus easy to distinguish. An article isn't a terminal since it has multiple alternatives. -Per On Wed, Mar 10, 2010 at 12:47 PM, Mike K wrote: > In PAIP section 2.3, Norvig gives an example of a generative grammar: > > ;; common lisp > (defparameter *simple-grammar* >  '((s

Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-11 Thread Per Vognsen
The way to go is definitely symlinks or hard links, not classpath hijinks. The only problem is that Java's filesystem API has no support for links, so you'll probably need to use OS-specific command line calls. Not too bad though. -Per On Thu, Mar 11, 2010 at 11:07 AM, Brent Mill

Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-11 Thread Per Vognsen
problems. -Per On Thu, Mar 11, 2010 at 1:45 PM, Alex Osborne wrote: > Brent Millare writes: > >> Since leiningen downloads everything to a local repo, can't we do away >> with copies and use symlinks if they are supported by the filesystem? >> I feel there should be

Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-11 Thread Per Vognsen
jars in its lib/ directory. A bigger project can easily have well over a hundred megabytes of lib/ jars. Now multiply that by the number of active clone branches (let's say a few dozen) and you're looking at a few gigabytes of waste. -Per On Thu, Mar 11, 2010 at 2:26 PM, Alex Osborne w

Re: proposal for core arithmatic functions

2010-03-13 Thread Per Vognsen
a compile-time reduce: ([x y & more] (reduce (fn [a b] `(+ ~a ~b)) (cons x (cons y more -Per -- 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 me

Re: proposal for core arithmatic functions

2010-03-13 Thread Per Vognsen
ed only when calls to the function are resolvable at compile time. While nicer than plain macros (as you can still treat the function as a first-class value at run time) they are still not semantically transparent because of the possibility of var rebinding. -Per -- You received this message because yo

Re: proposal for core arithmatic functions

2010-03-13 Thread Per Vognsen
loads. -Per On Sat, Mar 13, 2010 at 3:23 PM, Per Vognsen wrote: > On Sat, Mar 13, 2010 at 3:03 PM, Konrad Hinsen > wrote: >> On 13 Mar 2010, at 03:32, Jonathan Shore wrote: >> >>> Could + and other operators be changed to a macro mapping rather than the >>> cur

Re: take-to-first & partition-when

2010-03-17 Thread Per Vognsen
That implementation of partitions feels really low level. If you implement the monadic version of partition-when (which I call partition-where in my own code), it looks as simple as this: (defn partitions [xs] (run-seq (m-partition-where (const [false true]) xs))) -Per On Wed, Mar 17, 2010 at

Re: Java method call irritation

2010-03-18 Thread Per Vognsen
Is there any reason why a .method occurrence in non-operator position doesn't just do the closure wrapping automagically? -Per On Thu, Mar 18, 2010 at 9:50 PM, Stuart Halloway wrote: > memfn is from the depths of time and should be deprecated -- it is idiomatic > to write an anonymou

Re: Java method call irritation

2010-03-18 Thread Per Vognsen
s)) (map (with-args (.getRGB image 10 10)) [.getRed .getGreen .getBlue]) -Per On Fri, Mar 19, 2010 at 4:30 AM, Michael Gardner wrote: > On Mar 18, 2010, at 10:55 AM, Per Vognsen wrote: > >> Is there any reason why a .method occurrence in non-operator position >> doesn

Re: type hint puzzler

2010-03-18 Thread Per Vognsen
My guess from looking at the API documentation for ResultSet is that it doesn't know which of the several one-parameter overloads of getObject to choose. Presumably you want the integer one, so try (.getObject rs (int i)). -Per On Fri, Mar 19, 2010 at 12:08 PM, cageface wrote: > I

Re: scoped local memoize

2010-03-18 Thread Per Vognsen
al objects in nursery). In a Platonic paradise, the cache could even be allocated and freed without any GC involvement whatosever due to the magic of HotSpot's escape analysis. But that seldom works as widely in practice as one might hope and I expect it wouldn't in this example. -Per On

Re: Java method call irritation

2010-03-19 Thread Per Vognsen
On Fri, Mar 19, 2010 at 2:46 PM, Konrad Hinsen wrote: > On 18 Mar 2010, at 16:55, Per Vognsen wrote: > >> Is there any reason why a .method occurrence in non-operator position >> doesn't just do the closure wrapping automagically? > > There is two reasons I can think

Re: Java method call irritation

2010-03-19 Thread Per Vognsen
I don't think passing symbols around and having special case behavior scattered around different functions is going to help beginners. If anything, it would confuse them when they try to treat .methods as first-class functions in their own code and discover that it doesn't work. -Per O

Instance predicates for deftyped types

2010-03-19 Thread Per Vognsen
is to the `(do ...) block in deftype's implementation: (defn ~(symbol (str name "?")) [x#] (instance? ~classname x#)) It would also be nice if the class itself was exposed under some standardized name, e.g. (symbol (str ~name "-class"))). Any reason th

Re: Instance predicates for deftyped types

2010-03-19 Thread Per Vognsen
Thanks, I had seen that ::Foo use and was a bit confused. Now it all makes sense. It would still be nice to have an auto-generated name?-style predicate in deftype, I think. -Per On Fri, Mar 19, 2010 at 7:44 PM, Meikel Brandmeyer wrote: > Hi, > > On Mar 19, 12:09 pm, Per Vogns

Re: Instance predicates for deftyped types

2010-03-19 Thread Per Vognsen
It's pretty common in the Lisp world at large. For example, Common Lisp's (defstruct foo ...) automatically defines a foo-p predicate. -Per On Fri, Mar 19, 2010 at 7:53 PM, Konrad Hinsen wrote: > On 19.03.2010, at 13:50, Per Vognsen wrote: > >> It would still be nice to

Re: Simple functional programming lexicon?

2010-03-19 Thread Per Vognsen
strength of the language compared to, say, Haskell. -Per On Thu, Mar 18, 2010 at 3:13 AM, David Nolen wrote: > On Wed, Mar 17, 2010 at 4:09 PM, Konrad Hinsen > wrote: >> >> On 17 Mar 2010, at 20:54, David Nolen wrote: >> >>> But seriously, in my personal opinion Mo

Re: indexing only some elements of a sequence...

2010-03-20 Thread Per Vognsen
Learn to love scan: http://gist.github.com/338682 -Per On Sat, Mar 20, 2010 at 12:13 PM, Douglas Philips wrote: > Hello all, >   I'm new to clojure, but not lisp. >   I'm looking for a functional way to index/number only some items of a > list. > >   For example, I

Re: indexing only some elements of a sequence...

2010-03-20 Thread Per Vognsen
Aha! I Googled for scan in seq-utils and didn't find anything. It would be nice if people stuck to standard terminology that has a continuous history going back to the early 60s. -Per On Sat, Mar 20, 2010 at 9:40 PM, Steve Purcell wrote: > Which looks the same as clojure.contrib.seq/re

Re: indexing only some elements of a sequence...

2010-03-20 Thread Per Vognsen
ns. I find recognizability and memorability is usually a more important metric. Anyway, I don't want to derail this thread any further. :) -Per On Sat, Mar 20, 2010 at 10:16 PM, Meikel Brandmeyer wrote: > Hi, > > On Sat, Mar 20, 2010 at 09:50:12PM +0700, Per Vognsen wrote: >&g

Re: indexing only some elements of a sequence...

2010-03-20 Thread Per Vognsen
One last thing: On Sat, Mar 20, 2010 at 10:16 PM, Meikel Brandmeyer wrote: > Hi, > > On Sat, Mar 20, 2010 at 09:50:12PM +0700, Per Vognsen wrote: >> Aha! I Googled for scan in seq-utils and didn't find anything. It >> would be nice if people stuck to standard terminolog

Printing promises

2010-03-21 Thread Per Vognsen
hierarchy. Maybe someone more familiar with deftype can figure this one out. For now, what I have is good enough to get on with my immediate coding. -Per -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: Printing promises

2010-03-22 Thread Per Vognsen
On Mon, Mar 22, 2010 at 1:43 PM, Meikel Brandmeyer wrote: > Hi, > > On Mar 22, 7:13 am, Per Vognsen wrote: > >> As a solution, I factored the reify out into a deftype: >> >> http://gist.github.com/339834 > > A short note: you don't have to use :keyword

Re: General question: Petri nets and STM in clojure

2010-03-22 Thread Per Vognsen
tool here. -Per On Mon, Mar 22, 2010 at 5:45 PM, alux wrote: > Hi Andrzej, > > I'm not a Petri net specialist too, but I dont see how one could > simulate the view of a Clojure programmer onto STM, without simulation > too the stuff programmers doesnt see: Richs under-the

Re: Why I have chosen not to employ clojure

2010-03-22 Thread Per Vognsen
Java developer-oriented application with a good out-of-box experience on all platforms. Shell scripts for UNIX and installers for Windows and OS X would go a long way towards improving that for Clojure. -Per On Mon, Mar 22, 2010 at 6:31 PM, Luc Préfontaine wrote: > Is my first impression right

Re: Why I have chosen not to employ clojure

2010-03-22 Thread Per Vognsen
Note that I didn't propose an installer except for OS X and Windows. Only a DWIM shell script. -Per On Mon, Mar 22, 2010 at 7:04 PM, Ramakrishnan Muthukrishnan wrote: > On Mon, Mar 22, 2010 at 5:13 PM, Per Vognsen wrote: >> good example of a Java developer-oriented applicati

Re: questions on extending protocols

2010-03-22 Thread Per Vognsen
ult implementations in terms of the core protocol functions via mixins. This is how Scala's Seq trait is designed: http://www.scala-lang.org/docu/files/api/scala/Seq.html -Per -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: questions on extending protocols

2010-03-22 Thread Per Vognsen
ull off this code transformation entirely in-language with CL-style compiler macros while leaving alone references to protocol-function in non-operator position. -Per -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

Re: questions on extending protocols

2010-03-22 Thread Per Vognsen
ining an :expected-protocol field and comparing its value to protocol-function's protocol. -Per On Mon, Mar 22, 2010 at 11:24 PM, Per Vognsen wrote: >>>> lookup (find-protocol-method) over the method invocation itself. Is that >>>> the >>>> right

Re: Help optimizing array-to-integer operation?

2010-03-23 Thread Per Vognsen
jure reads 0xFF as the _signed_ integer 255. I would expect it to be -1. For example, (every? #(= % (bit-and -1 %)) (range -128 128)) evaluates to true. This looks like a genuine bug. -Per On Tue, Mar 23, 2010 at 7:08 PM, Konrad Hinsen wrote: > On 23.03.2010, at 08:55, Raph wrote: > >>

Re: Help optimizing array-to-integer operation?

2010-03-23 Thread Per Vognsen
Sorry, I didn't put that right. 0xFF would only be -1 as a signed byte. What I'm saying is that the interaction between the type system of integers and the reader's hexadecimal notation is pretty surprising to me. In particular, (byte 0xFF) throws an error. -Per On Tue, Mar 23,

Re: Counting vowels, take II.

2010-03-23 Thread Per Vognsen
coll (reductions #(if (pred %2) (rest %1) %1) src coll))) -Per On Tue, Mar 23, 2010 at 6:53 PM, Douglas Philips wrote: > Last week, Per Vognsen answered my first version of this question, how can I > number just the vowels in a string: > http://groups.google.com/group/clojure/msg/22186113b36041f1

Re: Nubie Question

2010-03-23 Thread Per Vognsen
and consider whether you're sure you really need references. You haven't supplied enough context for us to make that call. -Per On Tue, Mar 23, 2010 at 8:35 PM, WoodHacker wrote: > I understand how conj works.    But how do you add a value to a > persistent vector?    You have to

Re: Help optimizing array-to-integer operation?

2010-03-23 Thread Per Vognsen
Interesting. It's Clojure 1.2.0-master-SNAPSHOT as of last week: Clojure 1.2.0-master-SNAPSHOT user=> 0xff 255 user=> (byte 0xff) java.lang.IllegalArgumentException: Value out of range for byte: 255 (NO_SOURCE_FILE:0) So, this looks like a new issue. Rich? -Per On Tue, Mar 23, 2010

Re: Accidentally Retaining Head?

2010-03-23 Thread Per Vognsen
It doesn't seem very accidental: the namespace binding for 'trees' is retaining the head. You probably want to wrap it in a function: (defn trees [] ...) -Per On Tue, Mar 23, 2010 at 9:40 PM, aria42 wrote: > Hi, >  I was experimenting with some code and I had an largis

Re: Accidentally Retaining Head?

2010-03-23 Thread Per Vognsen
of any higher generations. -Per On Tue, Mar 23, 2010 at 9:49 PM, aria42 wrote: > Whoops duh. That was silly, far to early on the west coast. > > On Mar 23, 7:46 am, Per Vognsen wrote: >> It doesn't seem very accidental: the namespace binding for 'trees' is >> r

Re: Why I have chosen not to employ clojure

2010-03-23 Thread Per Vognsen
Stuart's book is by all accounts excellent, but I'm not sure we want to be in the situation that Ruby once was in, where buying a book (PragProg's Pickaxe book) was virtually a prerequisite for getting started. -Per On Tue, Mar 23, 2010 at 10:11 PM, Brian Hurt wrote: > > &

Re: ANN: labrepl, making Clojure more accessible

2010-03-23 Thread Per Vognsen
This is awesome, Stuart. With the live web server, a great addition would be if the embedded code snippets would be interactively runnable and tweakable right there in the web page. I'll see about hacking that in myself. -Per On Tue, Mar 23, 2010 at 9:13 PM, Stuart Halloway wrote: > The

Re: The % Schemer Series - are they worth the money?

2010-03-23 Thread Per Vognsen
pers. One of my favorite Lisp books is Christian Quiennec's Lisp in Small Pieces. Though it's long out of print, you can probably find used copies. I won't mention the usual suspects like SICP and PAIP. -Per On Tue, Mar 23, 2010 at 10:37 PM, Sean Devlin wrote: > Hey folks, > I&

Re: Counting vowels, take II.

2010-03-23 Thread Per Vognsen
like range are not really lazy but only chunky-lazy. You can verify this by replacing (range 10) by (range 100) and noting that the trace stops at the 32nd element (chunks are currently 32 elements wide). So, everything is as lazy as can be, given the input sequences. -Per On Wed, Mar 24, 2010 a

Re: listing factors of a number

2010-03-23 Thread Per Vognsen
ojure but there seem to be a few floating around in Java. -Per On Wed, Mar 24, 2010 at 3:35 AM, kotor wrote: > On Mar 23, 1:02 pm, Glen Rubin wrote: >> Does anyone know of any existing libraries for clojure that has code >> which is optimized to list all of the factors of any gi

Named arguments in HEAD and prettier default arguments for :keys destructuring

2010-03-23 Thread Per Vognsen
t do you think? I hacked this into my local version of core.clj's destructure and it feels very natural to me. -Per -- 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

Re: Clojure/LLVM

2010-03-23 Thread Per Vognsen
version of LuaJIT 2.0, but he had already done LuaJIT 1.0, and he is arguably one of the world's top experts in this area. Besides, one of the Clojure's main raisons d'etre is the vast pool of existing libraries in the JVM (and now CLR) world to draw from. -Per On Wed, Mar 24,

Re: Help optimizing array-to-integer operation?

2010-03-24 Thread Per Vognsen
I never said automatic overflowing is a good thing per se. The problem is that the expectations set by hexadecimal notation are violated. When I write 0xFF, I don't mean the abstract mathematical number 255; I mean the number whose bit representation (e.g. one's complement for signe

Re: determining index number for item in list

2010-03-24 Thread Per Vognsen
ndex. But supposing you did, this is an instance of a more general problem: determining the index (if any) of a number in a sorted sequence. Something like this: (defn index-in-sorted-seq [x s] (loop [s s, i 0] (when (seq s) (cond (= x (first s)) i (> x (first s)) (recur

Re: determining index number for item in list

2010-03-24 Thread Per Vognsen
On Wed, Mar 24, 2010 at 8:39 PM, Per Vognsen wrote: > On Wed, Mar 24, 2010 at 8:21 PM, Glen Rubin wrote: >> I wrote the following code to produce a lazy sequence of the triangle >> numbers.  (triangle numbers are the series of numbers: 1, 1+2, 1+2+3, >> etc...)

Re: Parsing parameters in clojure.core

2010-03-24 Thread Per Vognsen
It would be nice if the compiler handled these things with greater cleverness. In the mean time, some macros might be in order. I'd also like to add that clojure.core is not generally an exemplar of style. :) -Per On Wed, Mar 24, 2010 at 11:58 PM, Sean Devlin wrote: > It'

Re: Nubie Question

2010-03-25 Thread Per Vognsen
def cannot produce that error. You probably mean that it originates with some reference to savedColors that is expecting a sequence. You must explicitly dereference savedColors by prefixing it with @ to get at the contained value: user> (def saved-colors (atom [1, 2])) #'user/saved-colors

Re: database management: curing lock issues

2010-03-25 Thread Per Vognsen
Are the writes commutative? Since you are using pmap, I presume so. In that case, you could funnel the writes through an agent serving as a queue. -Per On Thu, Mar 25, 2010 at 9:59 PM, Scott wrote: > id prefer best practices if possible > > typically, cheating has consequences down

Re: converting long string to number

2010-03-25 Thread Per Vognsen
123123")) java.math.BigInteger Of course, it might also pose a bit of a security threat: user> (read-string "#=(println \"I OWN YOU NOW!\")") I OWN YOU NOW! nil :) -Per On Fri, Mar 26, 2010 at 5:47 AM, Chas Emerick wrote: > Glen, > > You want (java.math.BigIntege

Re: converting long string to number

2010-03-25 Thread Per Vognsen
In those hills yonder in the lands of Common Lisp, it's usually considered good practice to blast the entire read table save for what you need when you deal with untrusted data. Barring that, a better option might be a more modular reader: read-number, read-symbol, etc. -Per On Fri, Mar 26,

Re: concurrency and rand-int

2010-03-25 Thread Per Vognsen
dom-number generator." Look at java.util.Random for local RNGs. In the long term, it might make sense for core's rand to refer to a *random-number-generator* var that defaults to a shared thread-safe RNG but can be rebound per thread in cases like yours to reduce contention. In the short term

Re: ^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Per Vognsen
Look at clojure.contrib.repl-utils/add-break-thread!: http://richhickey.github.com/clojure-contrib/repl-utils-api.html -Per On Fri, Mar 26, 2010 at 10:20 AM, Douglas Philips wrote: > I've been using clojure 1.1.0 (via MacPorts clojure+rlwrap) and every time I > type Control-C, it ki

Re: Choosing a Clojure build tool

2010-03-25 Thread Per Vognsen
arate pieces of functionality that you happen to use the build tool to invoke. Why this obsession with integration and unified configuration? -Per On Fri, Mar 26, 2010 at 1:55 AM, Chas Emerick wrote: > I published a blog post earlier today, along with a short screencast that > might be

Re: ^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Per Vognsen
You can put a user.clj file in your class path. -Per On Fri, Mar 26, 2010 at 11:42 AM, Douglas Philips wrote: > On 2010 Mar 25, at 11:29 PM, Per Vognsen wrote: > >> Look at clojure.contrib.repl-utils/add-break-thread!: >> >> http://richhickey.github.com/clojure-con

Re: Choosing a Clojure build tool

2010-03-25 Thread Per Vognsen
n the Unix world) that does that. That's it. It doesn't need to be part of the build system and shouldn't be. I can call functions in the build system to supply the relevant arguments. If the build tool and library is well designed, the added value of integration in this example sh

Re: Choosing a Clojure build tool

2010-03-25 Thread Per Vognsen
On Fri, Mar 26, 2010 at 12:59 PM, Chas Emerick wrote: > > On Mar 26, 2010, at 12:59 AM, Per Vognsen wrote: > >> On Fri, Mar 26, 2010 at 11:50 AM, Chas Emerick >> wrote: >>> >>> Because they're common processes that are ideally built once, and then >

Re: concurrency and rand-int

2010-03-26 Thread Per Vognsen
ber it generated. That would mean you could initialize your own instance of the algorithm with the last number you saw it output and immediately duplicate all its future output. -Per -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gr

Infixup: DWIM hoisting and splicing in the reader

2010-03-31 Thread Per Vognsen
8 9 10 11 12 13 14 15 8 9 10 11 12 13 14 15 16 17) user=> (0 `cons` 2 `cons` [1 2] `(map +)` [3 4]) (0 2 4 6) I gisted my diff, in case anyone wants to play around with this: http://gist.github.com/350244 I withhold judgement on its ultimate merits. :) -Per -- You received this message be

Re: characters permitted in symbols??

2010-04-01 Thread Per Vognsen
oes that work by "accident" (or by undocumented permissiveness)? >> Is there someplace else that I should for an answer to this? > > The documentation is authoritative. Are you serious? It is neither complete nor consistent. How can it be authoritative? -Per -- You rece

Re: characters permitted in symbols??

2010-04-01 Thread Per Vognsen
ind, it is very strange to me that you would suggest treating it as authoritative for the sake of writing code. A more realistic answer would be that much about Clojure is still in flux and that you shouldn't count too strongly on things staying the same, even if it's in the documentation.

Re: "," is REAL whitespace...

2010-04-01 Thread Per Vognsen
It doesn't feel right only if you still think you are programming in an Algol-style language where , is a separator token. I can't imagine this is going to change. -Per On Fri, Apr 2, 2010 at 12:37 PM, Frank Siebenlist wrote: > Even though the specs clearly say that commas are wh

Re: REPL and its command prompt

2010-04-02 Thread Per Vognsen
. It feels more natural for a line-oriented REPL. -Per On Fri, Apr 2, 2010 at 2:23 PM, Michael Jaaka wrote: > Hi! > > I think that I've found inconsistency in REPL behavior. > Just press ENTER in REPL and you got new command prompt. > This shouldn't work like this. New line for

Re: "," is REAL whitespace...

2010-04-02 Thread Per Vognsen
Common Lisp, PLT Scheme's [ and ] as synonyms for ( and ), etc. -Per On Fri, Apr 2, 2010 at 6:10 PM, Mark J. Reed wrote: > try this one: > (list,1,2,3) > :) > Per: I'd say it's also weird if you're coming from a Lisp background - just > weird in the opposite direc

Re: REPL and its command prompt

2010-04-02 Thread Per Vognsen
1.2.0-master-SNAPSHOT user=> (+ 1 1) 2 user=> 1 1 user=> user=> user=> user=> 1 1 user=> 1 2 3 1 2 3 user=> By the way, these transcripts were generated with the program 'script', which is available by default on most Unix systems. -Per On Sat, Apr 3, 2010 at 9:

Re: holding types or units in metadata vs pattern matching

2010-04-03 Thread Per Vognsen
types with an identity-based weak-key hash table. Anyway, the way things stand, your best kept is probably to wrap your data in some data structure. It could be as simple as [:frequency x] or {:tag :frequency, :value x}. -Per On Sat, Apr 3, 2010 at 5:47 AM, strattonbrazil wrote: > What's the

Re: holding types or units in metadata vs pattern matching

2010-04-03 Thread Per Vognsen
rewrap the results in the newtype wrapper. (Clojure's arithmetic tower isn't expressible via protocol-style single dispatch, so this is vastly simplified, but you get the idea.) -Per On Sat, Apr 3, 2010 at 3:18 PM, Per Vognsen wrote: > Unfortunately you can only attach metad

Statically scoped first-class labels with dynamic extent

2010-04-03 Thread Per Vognsen
atom trick was inspired by E's implementation of revocable capabilities. IMO, revocable capabilities is one of the most convincing demonstrations of the cross-cutting power of stateful side effects. Of course, that is also what makes them so dangerous. -Per -- You received this message becau

Re: STM and Garbage Collection

2010-04-03 Thread Per Vognsen
ation N without triggering the card-marking write barrier and forcing the generation 0 pieces to be hoisted into generation N. -Per On Sun, Apr 4, 2010 at 7:53 AM, verec wrote: > The two issues are orthogonal. > > Even if Clojure had been going for full copies to preserve > immutability, th

Re: STM and Garbage Collection

2010-04-03 Thread Per Vognsen
You talk of transactions, "persistent in-memory" and garbage collection. Are you sure you understand what persistence means here? It's a matter of efficient structural sharing of data structures rather than persistence in the database sense. -Per On Sat, Apr 3, 2010 at 9:13 PM,

Re: fn? question

2010-04-04 Thread Per Vognsen
(map #(fn? (when-let [x (resolve (symbol %))] @x)) ["map", "first", "nofun"]) should do the trick. But before you go ahead and do this, make sure it's what you actually need. -Per On Sun, Apr 4, 2010 at 3:06 PM, Manfred Lotz wrote: > Hi there, > > I c

Re: Question about 'chains' of derefs a request for better ideas

2010-04-04 Thread Per Vognsen
vided transformation function. A lazy-ref-set function would impose a much stricter discipline on the user in order to maintain laziness. All the usual caveats about full laziness apply: beware of space leaks, delayed side effects, etc. -Per On Sun, Apr 4, 2010 at 9:35 PM, Bob Hutchison wrote: &

Re: Question about 'chains' of derefs a request for better ideas

2010-04-04 Thread Per Vognsen
would give the false illusion that the user is dealing with a uniform abstraction when the semantics are really very different. Certainly lazy vs non-lazy semantics are pragmatically very different in a language like Clojure and the difference shouldn't be swept under the rug. -Per On Mon, Apr

Re: Reorder a list randomly?

2010-04-04 Thread Per Vognsen
nd-int (- n m) (defn knuth-shuffle [xs] (let [v (vec xs)] (reduce #(swap-elts %1 %2 (rand-range %2 (count %1))) v (range (count v) -Per On Mon, Apr 5, 2010 at 3:14 AM, Linus Ericsson wrote: > Hello Clojure! > > Is there any straight-forward way to randomly re

Re: Reorder a list randomly?

2010-04-04 Thread Per Vognsen
huffle [xs] (let [v (transient (vec xs)), n (count v)] (persistent! (reduce #(swap-entries! %1 %2 (rand-range %2 n)) v (range n) -Per On Mon, Apr 5, 2010 at 10:19 AM, Lee Spector wrote: > > Since we're having a shuffle-a-thon, here's a version I wrote that I kind of

Re: Reorder a list randomly?

2010-04-04 Thread Per Vognsen
Wow, you're right. The partial laziness of his code was foiling my benchmark. -Per On Mon, Apr 5, 2010 at 11:05 AM, Mark Engelberg wrote: > On my system, knuth-shuffle performs several times faster than Spector's > recursive functional shuffle on smallish lists, and the differe

Re: Reorder a list randomly?

2010-04-04 Thread Per Vognsen
version of my code. The code itself is only three lines; the rest consists of very general purpose utilities that I find myself using again and again. http://gist.github.com/356035 -Per >  -Lee > > On Apr 5, 2010, at 12:11 AM, Per Vognsen wrote: > >> Wow, you're right. The p

Re: Mutually-referencing structures

2010-04-05 Thread Per Vognsen
, mutability (possibly implicit) is required. Here's an example of implicit mutation via delay/force: (deftype Account [owner balance]) (deftype Person [name accounts]) (declare per) (def per-account1 (Account (delay per) 42)) (def per-account2 (Account (delay per) 9000)) (def per (Person "

Re: Reorder a list randomly?

2010-04-05 Thread Per Vognsen
comparison, the time to sum that many elements with #(reduce + %) is about 50 ms. -Per On Mon, Apr 5, 2010 at 5:56 PM, Sean Devlin wrote: > If this is significantly faster than c.c.seq/shuffle, you should > submit a patch.  I know Rich was complaining about the speed of that > fn in th

Re: Mutually-referencing structures

2010-04-05 Thread Per Vognsen
relational database there are no direct pointers, only primary keys. A primary key is nothing more than an identifier; it becomes a specific reference only in the context of a table. So despite initial appearances it's actually a very familiar programming model. -Per -- You received this messa

Re: Set performance

2010-04-05 Thread Per Vognsen
imply isn't a persistent data structure. -Per On Mon, Apr 5, 2010 at 8:06 PM, ineol wrote: > It has nothing to do with Clojure but your colleague can look at the > Google collection library that contains an ImmutableSet. > http://guava-libraries.googlecode.com/svn/trunk/javado

Re: Mutually-referencing structures

2010-04-05 Thread Per Vognsen
ject graph traverser to find all references to a given object (e.g. gc.get_referrers() in Python) and then rewire those references on the fly. -Per On Mon, Apr 5, 2010 at 9:17 PM, Douglas Philips wrote: > On 2010 Apr 5, at 9:43 AM, Per Vognsen wrote: >> >> I already mentioned this in my or

Re: Mutually-referencing structures

2010-04-05 Thread Per Vognsen
osted. It's fair to say that while Clojure supports single assignment variables in the form of promises, they are not fundamental language-level constructs the way they are in languages like Prolog or Oz. You have to explicitly dereference them like any other IDeref. -Per On Tue, Apr 6, 20

Re: Mutually-referencing structures

2010-04-06 Thread Per Vognsen
le code is a pair of mutually cyclic lazy-seqs. http://gist.github.com/336461 -Per -- 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 - plea

Re: Mutually-referencing structures

2010-04-06 Thread Per Vognsen
rses on functional programming. A good paper to read is Cycle Therapy: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.64.2027 -Per -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@g

Re: Proxy and the "do" special form / var question

2010-04-07 Thread Per Vognsen
t's okay. I'd say it's the kind of thing that's convenient during development but will likely need to change later on. As such, I'd recommend he goes through the var with explicit dereferencing, or a functional interface with a similar level of indirection, so he can easily swa

Re: question about "into"

2010-04-07 Thread Per Vognsen
The second case is equivalent to (into [] [{:a 1 :b 2}]). You're passing a singleton list containing a single element which happens to be a map. -Per On Thu, Apr 8, 2010 at 7:35 AM, Base wrote: > Hi All - > > I have a question about into. > > When you run the into against a

Re: question about "into"

2010-04-08 Thread Per Vognsen
Indeed, and in the absence of single stepping (manual or automatic), some simple trace macros can be very useful. Here's what I use right now: http://gist.github.com/360102 -Per On Thu, Apr 8, 2010 at 8:38 PM, Sean Devlin wrote: > The REPL is you best friend whenever you have a quest

Re: A syntax question: positional & keyword

2010-04-08 Thread Per Vognsen
You can easily code positional keyword parameters yourself. It takes only a few minutes for a basic version. Here's an admittedly not very pretty example: http://gist.github.com/360145 -Per On Thu, Apr 8, 2010 at 9:13 PM, Sophie wrote: > On Apr 7, 7:56 am, David Nolen wrote: >&g

Re: iterating over a nested vector

2010-04-08 Thread Per Vognsen
Or you can separate concerns a bit more: (defn transpose [xs] (apply map vector xs)) Now Nurullah's original suggestion applies: (map #(apply max %) (transpose xs)) -Per On Fri, Apr 9, 2010 at 12:38 AM, James Reeves wrote: > On Apr 8, 1:13 pm, John Sanda wrote: >> [ >>

Re: Symbol resolution (between quote and eval/execution)

2010-04-08 Thread Per Vognsen
symbol isn't bound in this way, the compiler will call (resolve ...) on the symbol at compile time. This yields some var v. The code will then be evaluated as (deref v) at run time. -Per -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Symbol resolution (between quote and eval/execution)

2010-04-08 Thread Per Vognsen
On Fri, Apr 9, 2010 at 10:35 AM, Douglas Philips wrote: > On 2010 Apr 8, at 11:16 PM, Per Vognsen wrote: >> >> It's not a defn thing. If you write (do (a) (b) (c)) at the REPL, you >> should see the same exception. > > Yes, I would expect that since at

Re: Symbol resolution (between quote and eval/execution)

2010-04-08 Thread Per Vognsen
On Fri, Apr 9, 2010 at 11:26 AM, Douglas Philips wrote: > On 2010 Apr 8, at 11:48 PM, Per Vognsen wrote: >> >> The body of fn is still compiled in an expression context. When the >> compiler sees (fn [...] ...), it will introduce the bindings into the >> local environm

Re: ANN: lein-search

2010-04-08 Thread Per Vognsen
Nice! Towards a similar purpose, I wrote a little Emacs hack last week that web-scrapes clojars.org and inserts the artifact declaration at the cursor. Since I had to rely on their search feature, I couldn't do proper regular expression matching. -Per On Fri, Apr 9, 2010 at 11:23 AM, He

  1   2   >