Re: Help with decisions in threading macros

2015-11-05 Thread Oliver Hine
See also cond-> (Clojure core) and even condas-> 
(http://blog.juxt.pro/posts/condas.html)

Oliy

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: org-mode Clojure babel

2015-11-05 Thread Johannes Brauer
Hi!

Thank you for your hints.

...
One thing to do is look at your Org mode's ob-clojure.el and figure out whether 
it mentions cider.  (The older or "stable" versions use only slime or nrepl.)  
The Org website is a house of mirrors, but somewhere you should find a tidy 
tar.gz of a nicely assembled Org whose ob-clojure.el covers cider.
indeed, my version of ob-clojure did not mention cider. I’ve one in the house 
of mirrors (http://orgmode.org/cgit.cgi/org-mode.git/plain/lisp/ob-clojure.el) 
which does.
But the error message
 executing Clojure code block...
 let: Wrong number of arguments: (3 . 4), 1
remains.

Another thing that might go wrong, is that the cider-capable version of 
ob-clojure may try to detect whether it should use cider, nrepl, or slime.  
Detection might reach an unfortunate conclusion if Emacs had not loaded cider.  
Therefore, it might help to open a cider REPL buffer before opening any Org 
buffers.  (If I recall, Org Babel will need that REPL sooner or later anyway; 
it does not open its own REPL.)
I tried this too, but without success

Johannes

--
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google 
Groups "Clojure" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/clojure/PldQTR3yB3A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.





Staatlich anerkannte private Fachhochschule
NORDAKADEMIE
Gemeinnützige Aktiengesellschaft
Köllner Chaussee 11
25337 Elmshorn

Vorstand:
Prof. Dr. Georg Plate (Vorsitzender), Dipl.-Ing. Jörg Meier (stellv. Vorstand)

Vorsitzender des Aufsichtsrats:
Dr. h.c. Hans-Heinrich Bruns

Sitz:
Elmshorn, Amtsgericht Pinneberg, HRB 1682

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filtering lazy sequence on itself - Eratosthenes Sieve

2015-11-05 Thread Matthew Ulrich
Thanks, Sergio - this is a good way to construct the sieve.

It took me a little while to convince myself that it's the same, but it's 
definitely a good solution.

In general, I guess it's not possible to generate an infinite sequence that 
utilizes the tail-call optimization it makes sense as there is no 
"tail".

Have a good day,

Matty

On Wednesday, November 4, 2015 at 10:07:46 AM UTC-5, Sergio Rupena wrote:
>
> Hi
>
> You can try the following
>
> (defn dividers   [primes n]
>   (take-while #(<= (* % %) n) primes))
>
> (defn prime? [primes n]
>   (every? #(pos? (rem n %))
>   (dividers primes n)))
>
> (defn range-peek [coll]
>   (iterate inc (-> coll peek inc)))
>
> (defn sieve
>   ([] (cons 2 (lazy-seq (sieve [2]
>   ([primes]
>(let [p (->> primes
> range-peek
> (filter (partial prime? primes))
> first)]
>  (cons p (lazy-seq (sieve (conj primes p)))
>
> (last (take 1 (sieve)))
>
> This version keeps the visited primes in a vector so it will grow in 
> memory but won’t overflow otherwise.
>
> Sergio
>
> On 04 Nov 2015, at 15:44, Matthew Ulrich > 
> wrote:
>
> All - 
>
> I'm trying to generate a lazy sequence of primes using Erastosthenes Sieve 
> (from Abelson & Sussman) and am encountering some issues with lazy sequence.
>
> Here's what I have:
> ---
>
> (defn divisible?
>   [input numerator]
>   (= 0 (mod input numerator)))
>
> (defn sieve
>   [stream]
>   (lazy-seq
> (cons
>   (first stream)
>   (sieve (filter #(not (divisible? % (first stream))) (rest 
> stream))
>
> (def primes (sieve (iterate inc 2)))
>
> ---
>
> This is fine now when I:
>
> => (take 5 (drop 1000 primes))
> (7927 7933 7937 7949 7951)
>
>
> But when I:
>
> => (take 5 (drop 4000 primes))
> StackOverflowErrorclojure.lang.LazySeq.sval  (LazySeq.java:40)
>
>
> --
>
> I understand how the StackOverflow occurs with the filter on the 
> recursively generated sequence... however I can't think of a way to make 
> this work..
>
> I'm pretty new to clojure so I'm not very familiar with all of the 
> language features; is there some tool to help me realize this or should I 
> just go about the implementation in a different way?
>
> Thanks - have a great morning!
>
> Matty
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com 
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN][Book] Clojure for the Brave and True published, web site updated

2015-11-05 Thread Daniel Higginbotham
Thank you :)

For errata, you can send an email to Mackenzie 
Dolginow, macken...@nostarch.com.

Thanks!
Daniel

On Wednesday, November 4, 2015 at 12:06:51 AM UTC-5, Alan Thompson wrote:
>
> Hi Daniel - Just finished the book and think it is one of the best places 
> to start Clojure.
>
> Is there anyplace online that you are accepting errata?
>
> Thanks again,
> Alan
>
> On Fri, Oct 23, 2015 at 10:10 AM, John Gabriele  > wrote:
>
>> Excellent news! Looking forward to receiving my hard-copy, though haven't 
>> yet heard when it's shipping.
>>
>>
>>
>>
>> On Thursday, October 22, 2015 at 7:32:57 PM UTC-4, Daniel Higginbotham 
>> wrote:
>>>
>>> Clojure for the Brave and True  is now 
>>> available in print and ebook form , and the web 
>>> site has been updated to incorporate all the changes that went into the 
>>> print book. The web site remains 100% free :)
>>>
>>> In case you'd like to know more about the book: one of my goals was to 
>>> explain concepts thoroughly and entertainingly.
>>>
>>> "Thoroughly" because of my own difficulties learning Clojure. For 
>>> example, when I was first learning Clojure I thought the state constructs 
>>> were very neat, but I didn't have the conceptual foundation to truly 
>>> understand them and integrate them in my work. (I came from Ruby, where 
>>> concurrency was too much of a hassle to bother with.) I didn't even have a 
>>> clear idea of what a thread is. So, in the concurrency chapter, I try to 
>>> explain what concurrent and parallel programming are and why they matter 
>>> (and what threads are) before explaining atoms and refs and so forth.
>>>
>>> "Entertainingly" because otherwise it would be too tedious to complete 
>>> the book. Plus, as a learner I think it's easier to stay focused and 
>>> remember material if it makes you laugh. I'm really happy with the 
>>> concurrency chapter in this regard too, where concurrency is explained in 
>>> terms of the classic computer science example of Lady Gaga's song 
>>> "Telephone," also known as the "I cannot text you with a drink in my hand, 
>>> eh" problem.
>>>
>>> My other main goal was to provide the Clojure community with a free, 
>>> high-quality online book for beginners. There are other great free 
>>> resources available, like Clojure from the Ground Up (
>>> https://aphyr.com/tags/Clojure-from-the-ground-up), but I figure one 
>>> more doesn't hurt. Clojure is one of the best things to happen to my 
>>> career, and I hope my contribution helps the community :)
>>>
>>> Thanks!
>>> Daniel
>>>
>>>
>>> p.s. Thank you everyone who helped yesterday's launch go so well!
>>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN][Book] Clojure for the Brave and True published, web site updated

2015-11-05 Thread Alan Thompson
OK, great.  You may wish to add that contact info to the website or the
book page at NoStarch.com
Alan

On Thu, Nov 5, 2015 at 8:30 AM, Daniel Higginbotham 
wrote:

> Thank you :)
>
> For errata, you can send an email to Mackenzie Dolginow,
> macken...@nostarch.com.
>
> Thanks!
> Daniel
>
> On Wednesday, November 4, 2015 at 12:06:51 AM UTC-5, Alan Thompson wrote:
>>
>> Hi Daniel - Just finished the book and think it is one of the best places
>> to start Clojure.
>>
>> Is there anyplace online that you are accepting errata?
>>
>> Thanks again,
>> Alan
>>
>> On Fri, Oct 23, 2015 at 10:10 AM, John Gabriele  wrote:
>>
>>> Excellent news! Looking forward to receiving my hard-copy, though
>>> haven't yet heard when it's shipping.
>>>
>>>
>>>
>>>
>>> On Thursday, October 22, 2015 at 7:32:57 PM UTC-4, Daniel Higginbotham
>>> wrote:

 Clojure for the Brave and True  is now
 available in print and ebook form , and the
 web site has been updated to incorporate all the changes that went into the
 print book. The web site remains 100% free :)

 In case you'd like to know more about the book: one of my goals was to
 explain concepts thoroughly and entertainingly.

 "Thoroughly" because of my own difficulties learning Clojure. For
 example, when I was first learning Clojure I thought the state constructs
 were very neat, but I didn't have the conceptual foundation to truly
 understand them and integrate them in my work. (I came from Ruby, where
 concurrency was too much of a hassle to bother with.) I didn't even have a
 clear idea of what a thread is. So, in the concurrency chapter, I try to
 explain what concurrent and parallel programming are and why they matter
 (and what threads are) before explaining atoms and refs and so forth.

 "Entertainingly" because otherwise it would be too tedious to complete
 the book. Plus, as a learner I think it's easier to stay focused and
 remember material if it makes you laugh. I'm really happy with the
 concurrency chapter in this regard too, where concurrency is explained in
 terms of the classic computer science example of Lady Gaga's song
 "Telephone," also known as the "I cannot text you with a drink in my hand,
 eh" problem.

 My other main goal was to provide the Clojure community with a free,
 high-quality online book for beginners. There are other great free
 resources available, like Clojure from the Ground Up (
 https://aphyr.com/tags/Clojure-from-the-ground-up), but I figure one
 more doesn't hurt. Clojure is one of the best things to happen to my
 career, and I hope my contribution helps the community :)

 Thanks!
 Daniel


 p.s. Thank you everyone who helped yesterday's launch go so well!

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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 this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options,

Re: Filtering lazy sequence on itself - Eratosthenes Sieve

2015-11-05 Thread Sam Raker
Clojure doesn't do TCO with recursive functions--you have to use 
`loop`/`recur`[1]. This is one of the (thankfully few) "gotchas" in 
Clojure, at least/especially for people coming from other functional 
languages (or so I assume--coming from Python, I hadn't heard that much 
about TCO in the first place). There's a pretty good chance whichever intro 
book you're working through will talk about this in a chapter or so :)


[1] http://clojure.org/functional_programming#Functional 
Programming--Recursive Looping


On Thursday, November 5, 2015 at 10:01:44 AM UTC-5, Matthew Ulrich wrote:
>
> Thanks, Sergio - this is a good way to construct the sieve.
>
> It took me a little while to convince myself that it's the same, but it's 
> definitely a good solution.
>
> In general, I guess it's not possible to generate an infinite sequence 
> that utilizes the tail-call optimization it makes sense as there is no 
> "tail".
>
> Have a good day,
>
> Matty
>
> On Wednesday, November 4, 2015 at 10:07:46 AM UTC-5, Sergio Rupena wrote:
>>
>> Hi
>>
>> You can try the following
>>
>> (defn dividers   [primes n]
>>   (take-while #(<= (* % %) n) primes))
>>
>> (defn prime? [primes n]
>>   (every? #(pos? (rem n %))
>>   (dividers primes n)))
>>
>> (defn range-peek [coll]
>>   (iterate inc (-> coll peek inc)))
>>
>> (defn sieve
>>   ([] (cons 2 (lazy-seq (sieve [2]
>>   ([primes]
>>(let [p (->> primes
>> range-peek
>> (filter (partial prime? primes))
>> first)]
>>  (cons p (lazy-seq (sieve (conj primes p)))
>>
>> (last (take 1 (sieve)))
>>
>> This version keeps the visited primes in a vector so it will grow in 
>> memory but won’t overflow otherwise.
>>
>> Sergio
>>
>> On 04 Nov 2015, at 15:44, Matthew Ulrich  wrote:
>>
>> All - 
>>
>> I'm trying to generate a lazy sequence of primes using Erastosthenes 
>> Sieve (from Abelson & Sussman) and am encountering some issues with lazy 
>> sequence.
>>
>> Here's what I have:
>> ---
>>
>> (defn divisible?
>>   [input numerator]
>>   (= 0 (mod input numerator)))
>>
>> (defn sieve
>>   [stream]
>>   (lazy-seq
>> (cons
>>   (first stream)
>>   (sieve (filter #(not (divisible? % (first stream))) (rest 
>> stream))
>>
>> (def primes (sieve (iterate inc 2)))
>>
>> ---
>>
>> This is fine now when I:
>>
>> => (take 5 (drop 1000 primes))
>> (7927 7933 7937 7949 7951)
>>
>>
>> But when I:
>>
>> => (take 5 (drop 4000 primes))
>> StackOverflowErrorclojure.lang.LazySeq.sval  (LazySeq.java:40)
>>
>>
>> --
>>
>> I understand how the StackOverflow occurs with the filter on the 
>> recursively generated sequence... however I can't think of a way to make 
>> this work..
>>
>> I'm pretty new to clojure so I'm not very familiar with all of the 
>> language features; is there some tool to help me realize this or should I 
>> just go about the implementation in a different way?
>>
>> Thanks - have a great morning!
>>
>> Matty
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.