Re: What exactly is a form in Clojure?

2015-12-28 Thread David Sletten
n Lisp definitions don’t line up exactly with Clojure, but they are illuminating. Have all good days, David Sletten On Dec 28, 2015, at 11:16 AM, Ray Toal <ray.t...@gmail.com> wrote: > I think of it this way too but was really trying to get a formal definition, > if one exists. > > Whil

Re: why Clojure/Lisp is so fast

2014-02-18 Thread David Sletten
://www.clisp.org/propaganda.html See the section CLISP Performance at the bottom of the page. Have all good days, David Sletten On Feb 18, 2014, at 10:37 PM, Mars0i marsh...@logical.net wrote: It really depends on the benchmark and the programmer, and sometimes on the computer. And on what a person

Difficulty understanding (new?) behavior of identical?

2012-05-05 Thread David Sletten
Can anyone explain this change? (clojure-version) = 1.2.0 (let [x 8.9] (identical? x x)) = true Compared to: (clojure-version) = 1.4.0 (let [x 8.9] (identical? x x)) = false Thanks. David Sletten -- You received this message because you are subscribed to the Google Groups

Re: Difficulty understanding (new?) behavior of identical?

2012-05-05 Thread David Sletten
On May 5, 2012, at 3:06 PM, Daniel Solano Gómez wrote: On Sat May 5 14:53 2012, David Sletten wrote: Can anyone explain this change? (clojure-version) = 1.2.0 (let [x 8.9] (identical? x x)) = true Compared to: (clojure-version) = 1.4.0 (let [x 8.9] (identical? x x)) = false Well

Re: Difficulty understanding (new?) behavior of identical?

2012-05-05 Thread David Sletten
, this is probably not worth getting worked up about. Thanks, David Sletten On May 5, 2012, at 5:14 PM, Daniel Solano Gómez wrote: On Sat May 5 16:43 2012, David Sletten wrote: Thanks for your response Daniel. You explain WHAT is apparently happening here. However, I am still struggling

Re: Correct way to define the else clause of a cond form?

2011-07-06 Thread David Sletten
predicate for numerical equality.) Have all good days, David Sletten -- 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

Re: Correct way to define the else clause of a cond form?

2011-07-06 Thread David Sletten
that the predicate 'nil?' tests whether an object is 'nil'. You probably want to use the predicate 'empty?' to test whether your coin list is empty. Have all good days, David Sletten -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: Translating Java code with nested for loops

2011-06-29 Thread David Sletten
On Jun 29, 2011, at 1:45 AM, David Sletten wrote: (defn compute-contrib [daily-values total-values] (loop [contrib [] daily-values daily-values total-values total-values] (if (empty? daily-values) contrib (recur (conj contrib (* (first daily-values

Re: Translating Java code with nested for loops

2011-06-28 Thread David Sletten
? There are two obvious red flags with the code: -You have a variable called 'sum' which is really a product. -You never use index 0 of totalValues Have all good days, David Sletten -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group

Re: Translating Java code with nested for loops

2011-06-28 Thread David Sletten
On Jun 28, 2011, at 11:37 PM, David Sletten wrote: On Jun 28, 2011, at 8:20 PM, Bhinderwala, Shoeb wrote: The inputs are two arrays of type double of the same length – dailyValues and totalValues. The output is the array contrib of the same length. int n = dailyValues.length

Re: Cons vs List vs. ISeqs

2011-06-24 Thread David Sletten
an existing one. Lists and vectors are two concrete sequence types, and they have significant differences in terms of behavior and performance. But in Clojure you can 'cons' using a list or a vector. So the rules are a little different from other Lisps. Have all good days, David Sletten

Re: Small Problem: Which Strings Differ at One Location

2011-05-30 Thread David Sletten
zqr zbc aqd] 0) = ((abc zbc)) (match-position [abc abd aed axf zqr zbc aqd] 1) = ((abd aed aqd)) (match-position [abc abd aed axf zqr zbc aqd] 2) = ((abc abd)) (match-position [abc abd aed axf zqr zbc aqd qbd tbd tqr] 0) = ((abc zbc) (abd qbd tbd) (zqr tqr)) Have all good days, David Sletten

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 b.gh...@gmail.com 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 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 b.gh...@gmail.com wrote: I just needed a function

Re: sort-by reverse order?

2010-11-21 Thread David Sletten
Alex, There might be some useful info here: http://www.gettingclojure.com/cookbook:sequences#sorting Have all good days, David Sletten On Nov 22, 2010, at 12:07 AM, Alex Baranosky wrote: So for the case I had that method worked. I wonder though if I had wanted to sort by multiple keys

Re: string interpolation

2010-11-20 Thread David Sletten
://www.gettingclojure.com/cookbook:sequences#commas Have all good days, David Sletten On Nov 20, 2010, at 6:00 PM, HiHeelHottie wrote: I think ruby has nice string interpolation. You can put the following in a textfield that a user can modify This is a #{adjective} string. Then, you can take

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread David Sletten
a0 to point to a1? In any case, this behavior seems weird. Have all good days, David Sletten Stu Notice that when I redefined a, I only included one arity. If b were updated with the fn that a was redefined to, then (b 1 2) should have thrown an exception. Instead, it used the old

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-16 Thread David Sletten
to the function object itself, allowing for self-calling, even in anonymous functions. So I guess technically the self-referential 'a' in the function definition actually refers to the name inside the 'fn' form not the variable that is getting def'd? Have all good days, David Sletten

Re: Passing arguments from clojure to java

2010-11-16 Thread David Sletten
[] array out of a Clojure vector (clojure.lang.PersistentVector): (into-array String [I B]) So you wind up with this: (javax.swing.table.DefaultTableModel. (into-array String [I B]) 0) #DefaultTableModel javax.swing.table.defaulttablemo...@3ebc312f Have all good days, David Sletten -- You

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-16 Thread David Sletten
Ok, now I get it. The results you included weren't a hypothetical example, you were simply using a different version of Clojure. So in your 1.3 version, the second (b 1 2) does return -3? Are the macro expansions of 'defn' different? Have all good days, David Sletten On Nov 16, 2010, at 10

Clojure typing test

2010-11-15 Thread David Sletten
The StackOverflowError jumps over the lazy seq. Have all good days, David Sletten -- 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

Re: Performance of seq on empty collections

2010-11-15 Thread David Sletten
than that. Have all good days, David Sletten I was working on some code recently found that my biggest performance bottleneck was calling `seq` to check for emptiness. The calls to `seq` were causing lots of object allocation and taking noticeable CPU time. I switched to using

Re: Performance of seq on empty collections

2010-11-14 Thread David Sletten
Elapsed time: 2144.142 msecs nil This isn't so surprising though, considering that 'identical?' is the simplest possible test you could try--do two references point to the same object in memory? It can't get any more efficient than that. Have all good days, David Sletten I was working on some

Slogan help

2010-11-13 Thread David Sletten
good days, David Sletten -- 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

Being not Lisp is a feature?

2010-11-09 Thread David Sletten
I don't want to start any language wars, but this is funny: http://gosu-lang.org/comparison.shtml Have all good days, David Sletten -- 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

Re: Why isn't there a fold-right?

2010-11-07 Thread David Sletten
that other people won't be able to read your code: (defn foldr [f coll] (reduce #(f %2 %1) (reverse coll))) Have all good days, David Sletten On Nov 5, 2010, at 10:03 PM, Yang Dong wrote: Maybe because Clojure has a vector, and conj conjoins new elements to the end of the vector, so there's mere

Re: figuring out sets

2010-10-31 Thread David Sletten
: http://clojure.github.com/clojure/clojure.set-api.html Have all good days, David Sletten On Oct 31, 2010, at 10:55 PM, tonyl wrote: I guess I should've look harder (and ask more in the irc ;) it is a data structure and has a set fn too. #{} is just a reader macro for syntactic sugar

Re: How to simplify cond statements

2010-10-28 Thread David Sletten
. BTW, do you really mean to call 'add-to-result' and 'do-sth-else' with a map and a key but no value? Have all good days, David Sletten On Oct 28, 2010, at 8:49 PM, andrei wrote: Hi, I have a code similar to this: (def pairs (list [1 :a] [2 :b] [3 :c])) ... (loop [ps pairs, ret

I eat parentheses for breakfast

2010-10-27 Thread David Sletten
Some of you might enjoy the music video for the new Land of Lisp book: http://www.youtube.com/watch?v=HM1Zb3xmvMcfeature=player_embedded Have all good days, David Sletten -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

I eat parentheses for breakfast

2010-10-27 Thread David Sletten
Some of you might enjoy the music video for the new Land of Lisp book: http://www.youtube.com/watch?v=HM1Zb3xmvMcfeature=player_embedded Have all good days, David Sletten -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: precise numbers

2010-10-16 Thread David Sletten
] (* epsilon (Math/pow 2 (Math/floor (log2 x ) And finally, what is your response to the OP? You define 'same?' but place several caveats on its use. Are you warning that there is no general-purpose solution? Have all good days, David Sletten On Oct 16, 2010, at 7:05 PM, Steven E. Harris

Re: precise numbers

2010-10-14 Thread David Sletten
= x y epsilon Then you determine how strict epsilon needs to be: (float 12.3049 12.305) = false (float 12.3049 12.305 1e-6) = true (float= 12.305 12.3049) = true (float= 12.305 12.3049 1e-6) = false (float 12.305 12.3049 1e-6) = true Have all good days, David Sletten -- You received

Re: precise numbers

2010-10-13 Thread David Sletten
of 9's, which we must invariably do in a computer-based representation. Have all good days, David Sletten -- 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

Re: precise numbers

2010-10-13 Thread David Sletten
that satisfies your claim, so equality must hold. Have all good days, David Sletten On Oct 13, 2010, at 6:36 PM, Matt Fowles wrote: Felix~ You are correct that the sequence of numbers 0.9 0.99 0.999 ... asymptotically approaches 1; however, the number 0.... (with an infinite number

Re: precise numbers

2010-10-12 Thread David Sletten
This discussion may help: http://www.gettingclojure.com/cookbook:numbers#comparing-floats Have all good days, David Sletten On Oct 12, 2010, at 12:17 PM, cej38 wrote: I keep running into this type of problem: user= (- 12.305 12.3049) 9.9976694E-5 The computer (probably the JVM

Re: precise numbers

2010-10-12 Thread David Sletten
: 3463521440926951/281474976710656 Or in decimal: 12.304848840923025272 This is the best approximation for 12.3049. When you scale epsilon (0.1) by about 12, you can see that these two numbers are equal as expected in the sense defined by float=. Have all good days, David Sletten On Oct

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread David Sletten
]}) ([:headline this] [:headline is] [:headline me] [:points 1] [:points 2] [:points 3] [:comments 10] [:comments 20] [:comments 30]) Have all good days, David Sletten -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Attribution in the cookbook

2010-10-06 Thread David Sletten
the examples. What are your thoughts on this issue? Am I out of line, or is this a reasonable policy? Have all good days, David Sletten -- 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

Re: Changing keys in a map

2010-10-01 Thread David Sletten
On Oct 1, 2010, at 1:57 AM, Sean Corfield wrote: On Thu, Sep 30, 2010 at 12:52 AM, David Sletten da...@bosatsu.net wrote: Huh?! How many solutions do you want? You're starting to annoy me Sean. Sorry dude. I think it's really insightful to see lots of different solutions to small point

Re: Changing keys in a map

2010-09-30 Thread David Sletten
) (for [[k v] m] [(keyword (.toLowerCase k)) v]))) This will preserve the type of the map. (string-keys { :stuff 42 :like 13 :this 7 } ) = {THIS 7, LIKE 13, STUFF 42} (keyword-keys (string-keys { :stuff 42 :like 13 :this 7 } )) = {:stuff 42, :like 13, :this 7} Have all good days, David Sletten

Re: Changing keys in a map

2010-09-30 Thread David Sletten
On Sep 30, 2010, at 3:40 AM, Sean Corfield wrote: On Thu, Sep 30, 2010 at 12:30 AM, Mark Engelberg mark.engelb...@gmail.com wrote: Except that if you use .toUpperCase, you have to remember to type hint the input. Any time you call a Java method without type hinting, you take a significant

Re: How to write this in Clojure? Example from PAIP

2010-09-29 Thread David Sletten
-not =) = (2 3 2) Have all good days, David Sletten -- 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

Re: How to write this in Clojure? Example from PAIP

2010-09-29 Thread David Sletten
))) That's really nice Meikel. I was trying to remember how to do the new keywords, but I couldn't find an example. You have the default value for :test in there too. Interesting idea to replace 'remove not' with 'filter'. Have all good days, David Sletten -- You received this message

Re: Literal collection of numbers - prefer list or vector?

2010-09-26 Thread David Sletten
? (length (read-from-string '(+ 1 2))) 2 Have all good days, David Sletten -- 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

ANN: Clojure Cookbook

2010-09-26 Thread David Sletten
at the site and let us know what works and what needs to be fixed. And start thinking up your own recipes. Thanks. Have all good days, David Sletten -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure

Re: Byte Literals

2010-09-24 Thread David Sletten
Ah, right. Thanks. I'm not keeping up with my Clojure version numbers... On Sep 24, 2010, at 1:52 AM, Rasmus Svensson wrote: There's also 'bytes', 'byte-array' and 'into-array': (byte-array (map byte [1 2 3])) (into-array Byte/TYPE (map byte [1 2 3])) // raek -- You received this

Re: Byte Literals

2010-09-23 Thread David Sletten
) Or you can create a Java byte[] array: (def a (make-array Byte/TYPE 3)) But you still have to coerce: (aset a 0 (byte 2)) = 2 (aset a 0 2) = java.lang.IllegalArgumentException: argument type mismatch (NO_SOURCE_FILE:0) Have all good days, David Sletten On Sep 24, 2010, at 12:31 AM, HiHeelHottie

Re: Little LISPer and Ten Commandments

2010-09-22 Thread David Sletten
: http://groups.google.com/group/clojure/browse_thread/thread/c9bd4e79e5877a66 Have all good days, David Sletten On Sep 21, 2010, at 6:38 PM, ax2groin wrote: Newbie here, to both LISP and Clojure. A friend has lent me a copy of The Little LISPer and I've started working through it, using some web

Re: misunderstanding collection

2010-08-25 Thread David Sletten
)) signal) That's a lot easier for me to understand. Have all good days, David Sletten On Aug 25, 2010, at 10:06 AM, Glen Rubin wrote: After toying around at the REPL I realize that I have been working with a heretofore invalid understanding of collections. For example, working

Re: trouble using nested map fn

2010-08-23 Thread David Sletten
must do the actual work pairing each 'signal' and 'scalar'. Have all good days, David Sletten On Aug 23, 2010, at 11:26 AM, Glen Rubin wrote: I am trying to write a fn to correlate 2 signals using 3 nested map fn. I have 2 collections of data. THe first group of signals called target looks

Re: Simple Regex Question

2010-08-21 Thread David Sletten
Does this make the processing a little clearer? #(?=([ ab]))?([ab])\2* Have all good days, David Sletten On Aug 21, 2010, at 10:02 PM, CuppoJava wrote: Wow that's so short! Thanks Chouser! I will abstain from showing the awful hack that I've been working with currently. -Patrick On Aug

Re: [noob] Using dochars

2010-08-20 Thread David Sletten
\space \P \U \N \G \?) But now we've wound up with a sequence rather than a string specifically, so we need one more step: (apply str (map (fn [ch] (Character/toUpperCase ch)) Is this not pung?)) = IS THIS NOT PUNG? Have all good days, David Sletten On Aug 20, 2010, at 4:25 AM, probertm wrote: Hi

Re: questions about float operations

2010-08-20 Thread David Sletten
This may help explain things: http://groups.google.com/group/clojure/msg/325228e8b66923ac Have all good days, David Sletten On Aug 20, 2010, at 8:26 AM, bufo wrote: I am currently learning clojure by reading The Joy of Clojure and I have 2 questions on float opertions: - why does (+ 4.2

Re: Please help! Really simple function not working.

2010-08-10 Thread David Sletten
things by using loop: (defn count-zeros [l] (loop [num-list l result 0] (cond (empty? num-list) result (zero? (first num-list)) (recur (rest num-list) (inc result)) :else (recur (rest num-list) result Have all good days, David Sletten On Aug 9, 2010, at 8:24

Re: noob q: infinite loop recur

2010-08-10 Thread David Sletten
)) Have all good days, David Sletten -- 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

Re: shortcut for for comprehension

2009-04-21 Thread David Sletten
? Yes... (let [yields (ref 0)] (for [x (range 1000) :when (when (odd? x) (dosync (ref-set yields (inc @yields))) true) :while (= @yields 10)] x)) = (1 3 5 7 9 11 13 15 17 19) Is it advisable? No. Or should I just use (take 10 ) on the for ? Definitely yes. Aloha, David Sletten

Re: howto update with a constant when a function is expected?

2009-04-16 Thread David Sletten
, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr

Re: howto update with a constant when a function is expected?

2009-04-16 Thread David Sletten
...@a761ce: nil #r...@622e6: nil #r...@2689a7: nil #r...@173b39: nil) Also, in your second example above, I think it's more idiomatic to write (fn [_] (ref nil)) to demonstrate that you're ignoring the argument. Aloha, David Sletten --~--~-~--~~~---~--~~ You

Fixing Documentation Errors

2009-04-07 Thread David Sletten
What is the mechanism for reporting errors in documentation? For instance, the doc string is in the wrong place for 'rational?'. And 'quot' and 'rem' take parameters 'num' and 'div', but the documentation talks about denominators rather than divisors. Aloha, David Sletten

Re: Simple dosync/alter question

2009-04-06 Thread David Sletten
square-ref function didn't work, compare it to this: (defn square-ref [x] (dosync (alter foo (fn [_] (square x) Do you see the difference? Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Nested loops

2009-04-04 Thread David Sletten
(recur i (inc j ) The one nice thing about this is I can terminate the entire loop and return a value in one step. Otherwise the logic is a mess. Any suggestions out there? Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you

Re: Nested loops

2009-04-04 Thread David Sletten
possible suggestions rather than terminating with the first one. So I'll be dealing with sequences anyway. Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Advanced Practical Recursion in Lisp 1.0

2009-04-01 Thread David Sletten
useful. Try it out and let me know your opinions. Aloha, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from

Re: Trying to get a list of random numbers using repeat

2009-03-24 Thread David Sletten
. Aloha, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr

Re: Information Hiding

2009-03-23 Thread David Sletten
] (let [age (ref age)] {:first-name (fn [] first-name) :last-name (fn [] last-name) :sex (fn [] sex) :age (fn [] @age) :set-age (fn [new-age] (dosync (ref-set age new-age)))})) person= (def me (make-person David Sletten 39 male)) #'person/me person= ((me :first-name)) David

Month/Day names

2009-03-23 Thread David Sletten
Is there a simpler way to do this? (defn get-months [] (drop-last (.getMonths (java.text.DateFormatSymbols. (defn get-weekdays [] (drop 1 (.getWeekdays (java.text.DateFormatSymbols. Aloha, David Sletten --~--~-~--~~~---~--~~ You received

Re: Mapping a function over a map's values

2009-03-23 Thread David Sletten
str (iterate inc 1)) (iterate inc 1)) Aloha, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from this group

Re: Calling `str' on a LazySeq

2009-03-22 Thread David Sletten
is using 'apply': (apply str (filter even? (range 1 10))) = 2468 If you want commas between those elements, use 'interpose': (apply str (interpose , (filter even? (range 1 10 = 2, 4, 6, 8 Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message

Re: Calling `str' on a LazySeq

2009-03-22 Thread David Sletten
mention that the semantics have now changed a little. Sorry Mark. I guess I misunderstood what 'prn-str' does. I thought it was for I/O. I missed the print TO string part. Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you

Re: 08 and 09 are invalid numbers, but 01 through 07 are fine?

2009-03-15 Thread David Sletten
octal 010001 - 4097 not binary 010001 - 17 Sorry, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from

Re: 08 and 09 are invalid numbers, but 01 through 07 are fine?

2009-03-13 Thread David Sletten
, #o8, #xQUICKSAND (Of course, #36rCLOJURE = 27432414842 :-) ) Aloha, David Sletten --~--~-~--~~~---~--~~ 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

Re: Two quick questions on functions...

2009-03-10 Thread David Sletten
of bad. (I'll bet it's exactly what you expect to happen.) Aloha, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe

Re: letfn - mutually recursive local functions

2009-03-10 Thread David Sletten
, FLET implies non- recursive local function definition whereas LABELS suggests (mutually) recursive function(s). So, (letfn [(f [x] (+ x 2))] (f 8)) ; LABELS should ideally be: (let [f (fn [x] (+ x 2))] (f 8)) ; FLET Aloha, David Sletten --~--~-~--~~~---~--~~ You

List comprehension examples for Wikibook

2009-03-10 Thread David Sletten
from a copyrighted book? Aloha, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email

Problems with read-line

2009-03-09 Thread David Sletten
PushbackReader{ Can't be cast to BufferedReader... What's the policy for fixing something like this? Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: Help please: or function

2009-03-09 Thread David Sletten
verbatim in your example: (re-seq #(\w+)=(\S+) Aloha, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from

Re: Problems with read-line

2009-03-09 Thread David Sletten
. -Jason Sorry. I missed that. Thanks for the link. Aloha, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from

Clojure Cookbook

2009-03-09 Thread David Sletten
this in place to support the increased interest in Clojure that Stu Halloway's book will generate. Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Capitalize string

2009-03-08 Thread David Sletten
Is there a function to capitalize the first letter of a string or a better way than this idiotic code? (apply str (map #(if (zero? %2) (Character/toUpperCase %1) %1) clojuriffic (iterate inc 0))) Aloha, David Sletten --~--~-~--~~~---~--~~ You received

Re: Capitalize string

2009-03-08 Thread David Sletten
On Mar 8, 2009, at 2:45 AM, Joshua Fox wrote: How about this? user= (defn upper-first [s] (apply str (Character/toUpperCase (first s)) (rest s))) #'user/upper-first user= (upper-first a) A That certainly qualifies as less idiotic. :) Mahalo, David Sletten

filter-split

2009-03-07 Thread David Sletten
, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com

Re: filter-split

2009-03-07 Thread David Sletten
; (defn separate [f s] [(filter f s) (filter (complement f) s)]) This is exactly what I'm trying to avoid. I don't want to traverse the collection twice. Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: filter-split

2009-03-07 Thread David Sletten
) Aloha, David Sletten --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr

Re: float vs fraction (just playing around)

2009-03-06 Thread David Sletten
0.4 0.5 0.6 0.7 0.7999 0.8999 0. 1.0999 Whoops. Good thing I had an escape hatch. If you've read this far you'll want to take a look at the links Mark provided earlier. Aloha, David Sletten

let vs. let*

2009-03-06 Thread David Sletten
I see a lot of let* in macro expansions, but Clojure's let already behaves like Common Lisp's LET*. Is let* archaic? It seems to behave the same as let in terms of sequential binding. (let [x 8 y (inc x)] (list x y)) = (8 9) (let* [x 8 y (inc x)] (list x y)) = (8 9) Aloha, David Sletten

Re: Roman Numerals

2009-03-05 Thread David Sletten
it, but if you're interested you can compare. It's at http://github.com/tomfaulhaber/cl-format.) Thanks for the link Tom. I'd read mention of your work somewhere but hadn't had a chance to look at it yet. That's extremely cool that you've implemented FORMAT! Aloha, David Sletten

Re: Roman Numerals

2009-03-04 Thread David Sletten
and strings rather than nesting them. I don't think reduce would actually work here. As you see, the test (= n arabic) determines whether we continue working with the original num-list or proceed to the tail. I'm not sure of how to get that behavior with reduce. Aloha, David Sletten

When in Rome

2009-03-04 Thread David Sletten
in an AI Memo (AIM-8). Here's to McCarthy and Lisp. And here's to you, RIch, for carrying on the flame. Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Roman Numerals

2009-03-03 Thread David Sletten
it would be in CL with its additional set of grouping parentheses. When you can't fit both the predicate and the consequent expression on the same line it gets confusing. I'd appreciate any feedback regarding my Clojure style. Any more natural ways to do things? Aloha, David Sletten (def roman

member function

2009-03-02 Thread David Sletten
this alternative is alright: (some #{'a} '(a b c)) = a Is that the Clojure version of MEMBER? Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: member function

2009-03-02 Thread David Sletten
:a :b :e) Thanks for your example anyway. Mahalo nui loa (vielen dank), David Sletten --~--~-~--~~~---~--~~ 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

Re: member function

2009-03-02 Thread David Sletten
. Nice explanation. Thanks again Mark for the article. sheepish As you can see I haven't finished reading the whole thing yet. /sheepish Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure

Re: Clojure documentation problems

2009-02-25 Thread David Sletten
On Feb 19, 2009, at 2:52 AM, David Sletten wrote: The macros page at clojure.org (http://clojure.org/macros) has links to several points in the API page. The link to the if-not macro appears to be broken (http://clojure.org/api#if-not). There is no such entry in the API. The same holds

Re: Flatten a list

2009-02-24 Thread David Sletten
l)) (recur (rest l) result) true (recur (rest l) (cons (first l) result ) You young whipper snappers! Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group

Re: Flatten a list

2009-02-24 Thread David Sletten
On Feb 24, 2009, at 6:07 PM, David Sletten wrote: (defn kill-nil ([l] (kill-nil l '())) ([l result] (cond (nil? l) (reverse result) (nil? (first l)) (recur (rest l) result) true (recur (rest l) (cons (first l) result ) I forgot to ask

Clojure documentation problems

2009-02-19 Thread David Sletten
#condp). Their documentation is available via doc at the REPL though. In addition, the rationalize function was missing last week, but it has an entry now. So never mind that... Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you

Re: terminology question re: binding

2009-02-17 Thread David Sletten
On Feb 16, 2009, at 10:34 AM, Stuart Halloway wrote: David Sletten sent me this erratum: At the beginning of section 2.4 we have The symbol user/foo refers to a var which is bound to the value 10. Under the next subsection Bindings we have Vars are bound to names, but there are other

Re: terminology question re: binding

2009-02-17 Thread David Sletten
the global. ; bar still refers to global pung (let [pung 9] (list pung foo @bar)) = (9 8 8) Do I have it right now? Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post

Re: is mod correct?

2009-02-12 Thread David Sletten
: 938.675334 msecs But the multiply seems to have the edge in both expression and speed. The real hit would come with bignums, no? But as far as the routine use of MOD goes we're probably talking about fixnums 99% of the time. Aloha, David Sletten