Re: What exactly is a form in Clojure?

2015-12-28 Thread David Sletten
hat these Common 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 wrote: > I think of it this way too but was really trying to get a formal definition, > if one exists. > > While I'v

Re: why Clojure/Lisp is so fast

2014-02-18 Thread David Sletten
edges as much: http://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 wrote: > It really depends on the benchmark and the programmer, and sometimes on the > computer. An

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

2012-05-05 Thread David Sletten
nt numbers, 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. Howev

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: >> (cl

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 b

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

2011-07-06 Thread David Sletten
in terms of a single expression as a consequent. The need for enclosing parentheses disappears. Beware 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 g

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

2011-07-06 Thread David Sletten
total 20) 8.75 > (or (amount > 20) (= country "US") 9.75) > :else 10.0 ) predicate | consequent (= total 20) | 8.75 (or (amount > 20) (= country "US") 9.75) | :else 10.0 | ??? Not syntactically correct. Here's what you want to use: (cond (== tota

Re: Translating Java code with nested for loops

2011-06-28 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

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

Re: Translating Java code with nested for loops

2011-06-28 Thread David Sletten
s[i]; > > } > 1. Are you sure that this does what you want it to? 2. What does it do? 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

Re: Cons vs List vs. ISeqs

2011-06-24 Thread David Sletten
element, the 'rest' of the sequence, and allows you to construct ('cons') a new sequence from 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'

Re: Small Problem: Which Strings Differ at One Location

2011-05-30 Thread David Sletten
["abc" "abd" "aed" "axf" "zqr" "zbc" "aqd"] 1) => (("abd" "aed" "aqd")) (match-position ["abc" "abd" "aed" "axf" "zqr" "zbc" "aqd

Re: every-nth

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

Re: every-nth

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

Re: 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 multipl

Re: string interpolation

2010-11-20 Thread David Sletten
ial plus links here: http://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

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

2010-11-17 Thread David Sletten
1 only takes one arg now). But within a0 itself the references to 'a' are being resolved at runtime to a1 now, not as references to a0 as before. Are you saying that inside a0 Clojure detects that 'a' means something else now and recompiles a0 to point to a1? In any case, this beh

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

Re: Passing arguments from clojure to java

2010-11-16 Thread David Sletten
r takes either a java.util.Vector or an array of Object[]. To make a String[] 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" &q

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

2010-11-16 Thread David Sletten
it is bound within the function definition 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 i

Re: Performance of seq on empty collections

2010-11-15 Thread David Sletten
ould solve the OP's performance issue. I simply pointed out that he was testing two opposite things. > On Nov 14, 11:42 am, David Sletten wrote: >> On Nov 14, 2010, at 2:16 PM, Eric Kobrin wrote: >> >>> In the API it is suggested to use `seq` to check if coll is

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

Re: Performance of seq on empty collections

2010-11-14 Thread David Sletten
(identical? () ( (time (dotimes [_ iterations] (empty? () "Elapsed time: 2.608 msecs" "Elapsed time: 2144.142 msecs" nil This isn't so surprising though, considering that 'identical?' is the simplest

Slogan help

2010-11-13 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.

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@google

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

2010-11-07 Thread David Sletten
Or for those of you who prefer 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

Re: figuring out sets

2010-10-31 Thread David Sletten
t. Also check out the documentation for clojure.set: 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

Re: How to simplify cond statements

2010-10-28 Thread David Sletten
pair in a convenient way. 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 pai

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=HM1Zb3xmvMc&feature=player_embedded Have all good days, David Sletten -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

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=HM1Zb3xmvMc&feature=player_embedded Have all good days, David Sletten -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: precise numbers

2010-10-16 Thread David Sletten
if (> (+ eps 1.0) 1.0) (recur (* eps 0.5)) eps))) (defn scaled-epsilon [x] (* 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 gener

Re: precise numbers

2010-10-14 Thread David Sletten
<= 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 this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send e

Re: precise numbers

2010-10-13 Thread David Sletten
ber 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,

Re: precise numbers

2010-10-13 Thread David Sletten
cate the string 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 N

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 S

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

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread David Sletten
efn d-map [m] (apply concat (map (fn [[key val-list]] (map (fn [val] [key val]) val-list)) m))) (d-map {:headline ["this" "is" "me"] :points [1 2 3] :comments [10 20 30]}) ([:headline "this"] [

Attribution in the cookbook

2010-10-06 Thread David Sletten
purpose of improving 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

Re: Changing keys in a map

2010-09-30 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 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

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

Re: Changing keys in a map

2010-09-30 Thread David Sletten
STUFF" 42} (keyword-keys (string-keys { :stuff 42 :like 13 :this 7 } )) => {:stuff 42, :like 13, :this 7} 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 t

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

2010-09-29 Thread David Sletten
em %) coll) >(filter #(test item %) coll))) 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

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

2010-09-29 Thread David Sletten
') since we aren't passing in a list of keywords. (find-all 1 '(1 2 3 2 1) :test =) => (1 1) (find-all 1 '(1 2 3 2 1) :test not=) => (2 3 2) (find-all 1 '(1 2 3 2 1) :test-not =) => (2 3 2) Have all good days, David Sletten -- You received this message becaus

ANN: Clojure Cookbook

2010-09-26 Thread David Sletten
e a look 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 gro

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

2010-09-26 Thread David Sletten
least the Clojure printer is cooperating here. In Common Lisp the printer helps hide QUOTE too in the first line here: ? (read-from-string "'(+ 1 2)") '(+ 1 2) 8 ? (first (read-from-string "'(+ 1 2)")) QUOTE ? (length (read-from-string "'(+ 1 2)&qu

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

Re: Byte Literals

2010-09-23 Thread David Sletten
e java.lang.Byte java.lang.Byte) 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

Re: Little LISPer and Ten Commandments

2010-09-22 Thread David Sletten
chapter 9 dealing with the Y-Combinator implemented in Clojure. It's pretty weird: 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 f

Re: misunderstanding collection

2010-08-25 Thread David Sletten
level-1)) 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 to

Re: trouble using nested map fn

2010-08-23 Thread David Sletten
signal'. Finally, the innermost map 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 coll

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 workin

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

Re: [noob] Using dochars

2010-08-20 Thread David Sletten
"Is this not pung?") => (\I \S \space \T \H \I \S \space \N \O \T \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?"))

Re: noob q: infinite loop recur

2010-08-10 Thread David Sletten
tead, you need to rebind the variable 'words' to subsequent tails of the original list: (defn show [words] (loop [l words] (println (first l)) (if (empty? l) (println "DONE") (recur (rest l) And you probably want to test for the end of list before you pri

Re: Please help! Really simple function not working.

2010-08-09 Thread David Sletten
this 2-arity version. I personally prefer the first approach > (with a private helper function via defn-) or the last approach (with an > embedded loop). Hence "pretty much the same thing". :) Have all good days, David Sletten -- You received this message because you are su

Re: Please help! Really simple function not working.

2010-08-09 Thread David Sletten
(rest l) result Or you could simplify 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, D

Re: shortcut for for comprehension

2009-04-21 Thread David Sletten
he first 10 results. Is it possible? 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 ?

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

2009-04-16 Thread David Sletten
84427> # # clojure.lang@1fac852> #) > > In that case, here's something that reads more clearly to me: (take 10 (repeatedly #(ref nil))) => (# # # # # # # # # #) Also, in your second example above, I think it's more idiomatic to write (fn [_] (r

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

2009-04-16 Thread David Sletten
htforward: (repeat (count (list :old1 :old2 :old3)) :new) 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.c

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 "de

Re: Simple dosync/alter question

2009-04-06 Thread David Sletten
> Paul and David N. have already given you the right advice. But to help you understand why your 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 --~--~-~--~~--

Re: Nested loops

2009-04-04 Thread David Sletten
eral case, but you guys may be right that nested loops just aren't needed. Your example looks useful, Mark. In fact, for the real program I do want to collect all possible suggestions rather than terminating with the first one. So I'll be dealing with sequences anyway. Aloha,

Nested loops

2009-04-04 Thread David Sletten
(if match match (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 --~--~-~--~~~---~-

Re: speed question

2009-04-02 Thread David Sletten
le true)) (doto canvas (.setBounds 0,0,width height) (.setBackground (Color/BLACK)) (.createBufferStrategy 2) (.requestFocus)) (draw canvas Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message beca

Advanced Practical Recursion in Lisp 1.0

2009-04-01 Thread David Sletten
(rest l))) (rec (cons (first l) (rec (rest (rec (rest l ))) '(a b c d e)) => (e d c b a) Breathtaking in its elegance! I'm going to move forward with the negotiations, but I need to know if you, the Clojure com

Re: Is there already a function to apply functions to maps by key?

2009-03-26 Thread David Sletten
rogrammer {:language (fn [_] "Clojure") :iq # (+ 10 %)})) (upgrade (struct programmer "Bob" "C++" 120)) => {:name "Bob", :language "Clojure", :iq 130} Aloha, David Sletten --~--~-~--~~~---~--~~ You receive

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

2009-03-24 Thread David Sletten
's a good sign that a side effect has occurred--some state has obviously changed. Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: Mapping a function over a map's values

2009-03-23 Thread David Sletten
ly--it uses loop. Don't try this at home: (zipmap (map 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

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 this

Re: Information Hiding

2009-03-23 Thread David Sletten
only be accessed and changed by the existing support > functions? > One simple (simplistic?) way to guarantee privacy is through closures: (defn make-person [first-name last-name age sex] (let [age (ref age)] {:first-name (fn [] first-name) :last-name (fn [] last-name) :sex

Re: Calling `str' on a LazySeq

2009-03-22 Thread David Sletten
' explicitly > isn't a problem--I just thought I'd 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 --~--~-

Re: Calling `str' on a LazySeq

2009-03-21 Thread David Sletten
However, rather than relying on this behavior what you probably should be doing 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? (ran

Re: Which Java book(s) to order

2009-03-16 Thread David Sletten
482114/ ref=sr_1_1?ie=UTF8&s=books&qid=1237204784&sr=1-1 3. Learning Java http://www.amazon.com/Learning-Java-Pat-Niemeyer/dp/0596008732/ ref=sr_1_1?ie=UTF8&s=books&qid=1237204946&sr=1-1 Pretty up-to-date and covers a lot of ground. Aloha, David Sletten --~--~

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

2009-03-15 Thread David Sletten
> Umm, that's not really the correct value. Clojure gave you octal 010001 -> 4097 not binary 010001 -> 17 Sorry, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure&q

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

2009-03-13 Thread David Sletten
011, #o377, #xDEADBEEF, #36rZZZ (Base 36 anyone?) Illegal: #b2, #o8, #xQUICKSAND (Of course, #36rCLOJURE => 27432414842 :-) ) Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cloju

List comprehension examples for Wikibook

2009-03-10 Thread David Sletten
y are derived 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

Re: letfn - mutually recursive local functions

2009-03-10 Thread David Sletten
d 'let' similar to the distinction between LABELS and FLET in CL? In other words, FLET implies non- recursive local function definition whereas LABELS suggests (mutually) recursive function(s). So, (letfn [(f [x] (+ x 2))] (f 8)) ; LABELS

Re: Two quick questions on functions...

2009-03-10 Thread David Sletten
ith the same name > that allowed me to enter the arguments in a simpler manner. > > Also, it just feels odd. You don't get an error when defining the > same- > named function--but suddenly neither version works. That's a pretty > serious side-effect. So maybe this is just

Clojure Cookbook

2009-03-09 Thread David Sletten
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

Re: Problems with read-line

2009-03-09 Thread David Sletten
not sure what the resolution was, if any. > > -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

Re: Help please: or function

2009-03-09 Thread David Sletten
e basically defined the "word character" class \w verbatim in your example: (re-seq #"(\w+)=(\S+)" Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" gr

Problems with read-line

2009-03-09 Thread David Sletten
: public class LineNumberingPushbackReader extends 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

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 certain

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 rec

Re: filter-split

2009-03-07 Thread David Sletten
(recur (cons (first coll) trues) falses (rest coll)) > :else > (recur trues (cons (first coll) falses) (rest coll) Aloha, David Sletten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: filter-split

2009-03-07 Thread David Sletten
u look at separate in clojure.contrib.seq-utils its simple > and elegant; > (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 --~--~---

filter-split

2009-03-07 Thread David Sletten
ge 10)) => [(0 2 4 6 8) (1 3 5 7 9)] 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 unsu

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)] (

Re: float vs fraction (just playing around)

2009-03-06 Thread David Sletten
1) "How nice. 10 * 0.1 = 1" (> x 1) "Whoops. Good thing I had an escape hatch." :else (trap (+ x 0.1 (trap 0.1) 0.1 0.2 0.30004 0.4 0.5 0.6 0.7 0.7999 0.8999 0. 1.0999 "Whoops. Good

Re: Roman Numerals

2009-03-05 Thread David Sletten
issues when I wrote 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

When in Rome

2009-03-04 Thread David Sletten
thing". If you're using "when" as an expression, it has to produce a value even when the test fails. Why not just use "if" and make that value explicit? > It would certainly be a waste of 'when' in Clojure to reserve it for > side effects, since so much

Re: Roman Numerals

2009-03-04 Thread David Sletten
'() >> :else (let [[[arabic roman] & tail] num-list] >> (if (>= n arabic) >> (cons roman (arabic-to-roman (- n >> arabic) >>

Roman Numerals

2009-03-03 Thread David Sletten
c-aux seems to me harder to read in Clojure than 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 m

Re: "member" function

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

Re: "member" function

2009-03-02 Thread David Sletten
op-while #(not= % :a) (list :c :a :f :e :b :a :b :e)) > => (:a :f :e :b :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

"member" function

2009-03-02 Thread David Sletten
y verbose, and even the shortcut is kinda long: (some #(= % 'a) '(a b c)) => true Although this alternative is alright: (some #{'a} '(a b c)) => a Is that the Clojure version of MEMBER? Aloha, David Sletten --~--~-~--~~~---~--~~ You received

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 e

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

Re: Flatten a list

2009-02-24 Thread David Sletten
erse result) (nil? (first 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 sub

Clojure documentation problems

2009-02-19 Thread David Sletten
tp://clojure.org/api#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 --~--~-~--~~~---~--

  1   2   >