Re: IllegalArgumentException when running core.async example

2014-07-09 Thread Tobias Kortkamp
In judge try changing

  (let [out async/chan] ...)

to

  (let [out (async/chan)] ...)



On Wednesday, July 9, 2014 5:57:53 AM UTC+2, endbegin wrote:

 Just tried it with Clojure 1.6.0. Still no luck!



-- 
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: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 2:24 GMT+02:00 Bruce Wang br...@brucewang.net:

 You might want to check out this
 https://github.com/quux00/land-of-lisp-in-clojure


​I will look into it. But I learn most if I do it myself. ;-)​


-- 
Cecil Westerhof

-- 
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: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 5:11 GMT+02:00 Timothy Baldridge tbaldri...@gmail.com:

 Prefer vectors over quoted lists '(1 2) vs [1 2]. There's rarely a case
 (outside of macros) that you want the former.

 Instead of quoted lists of symbols: '(You cannot get that.) try strings
 You cannot get that


​That is what Conrad uses. I would think that strings are much better also,
but he says that there is a good reason to use a quoted list of symbols.
And I have not finished the book yet. So maybe he is right.

​


 Don't use defs inside defs. Instead move the defs to a global position and
 then use binding or set-var-root! to set them.


​I was not happy with it, but did not know better. At the moment I get
binding and set-var-root! not working.

​


 Better yet, use atoms to hold their contents, even better yet, pass the
 game state into each function and have each function return a new game
 state.

 Instead of:

 (defn walk [direction]
   ...
   (def ^:dynamic *location* (first edge))

 Use atoms like this:

 (def location (atom nil))

 (defn walk [direction]
   ...
   (reset! location (first edge))


​Yep, that would be better. I al-ready use atom in error-in-datastruct-p,
so why not here?

​


 Once you replace symbol lists with strings, you can easily do this instead
 of syntax quoting:

 (str There is a  (nth edge 2)  going  (nth edge 1) from here)


​As said: that was my idea also. I just finish the book to see if there is
a real reason to use a quoted list. If not I replace it.



 On Tue, Jul 8, 2014 at 6:24 PM, Bruce Wang br...@brucewang.net wrote:

 Hi Cecil,

 You might want to check out this
 https://github.com/quux00/land-of-lisp-in-clojure

 Cheers,
 Bruce


 On Wed, Jul 9, 2014 at 9:49 AM, Cecil Westerhof cldwester...@gmail.com
 wrote:

 I received the book land of lisp as a gift. I am trying to translate it
 to Clojure. In chapter 5 there is a text game engine. In the attachment my
 translation. What do you think of it?

 There are a few problems.
 - The book displays all the lines of a look on separate lines. In my
 case it is just one long line. Am I doing something wrong?

 - In Emacs Lisp you can use a function A in the definition of another
 function B before you declared function A. Is it correct that this is not
 possible in Clojure?

 - Al variables in land of lisp begin and end with an asterisk. As I
 understood it, you only do this for variables that can be changed. So I
 renamed some variables. Did I understand this correctly, or is the usage of
 asterisks for something else?


-- 
Cecil Westerhof

-- 
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: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 5:30 GMT+02:00 John Mastro john.b.mas...@gmail.com:

 Cecil Westerhof cldwester...@gmail.com wrote:
  - The book displays all the lines of a look on separate lines. In my
  case it is just one long line. Am I doing something wrong?

 No, you're not doing anything wrong. There's nothing in that data
 structure which would inherently cause it to print on multiple lines.

 If you're using Cider, you can enable automatic pretty-printing in the
 REPL, which would likely cause it to print on multiple lines. I think
 it's M-x cider-repl-toggle-pretty-printing.

 Or you could use a definition of look more like this, which uses println
 to print each item on its own line (not sure if you wanted to retain the
 parens or not, but both are easily doable).

 (defn look []
   (doseq [d [(describe-location *location* nodes)
  (describe-paths *location* edges)
  (describe-objects *location* objects *object-locations*)]]
 (println d)))


​That certainly looks better. The only problem is that the lines of the
different calls are still printed as one. But rewriting to use strings
would solve that problem. I just have to finish the book, to see if I can
change the lists to strings.​



 - In Emacs Lisp you can use a function A in the definition of another
  function B before you declared function A. Is it correct that this is
  not possible in Clojure?

 Correct, though you can declare it without defining it, e.g.
 (declare function-a).


​OK, good to know.​




  - Al variables in land of lisp begin and end with an asterisk. As I
  understood it, you only do this for variables that can be changed. So
  I renamed some variables. Did I understand this correctly, or is the
  usage of asterisks for something else?

 The earmuffs convention is related to dynamic variables. All global
 variables are dynamic in Common Lisp, but that's not the case in
 Clojure. You're creating dynamic variables (by using :dynamic metadata
 in your defs) but I didn't notice anywhere where you're using this
 feature (i.e. no binding or set! forms). Long story short, I would use
 earmuffs if the variables are dynamic but not otherwise.


​I read a little about it. And no, I do not use dynamic binding. So I
probably should use atoms. Is there a convention how to name atoms?​




 Speaking of global variables, I'd recommend only using def at top level
 (it creates global vars regardless of where you use it). Perhaps it
 would work to initialize them at top level with a null value, like
 (def something (atom nil)), and then set it later if/when appropriate,
 like (reset! something (first whatever)). As a plus, if you use
 atoms like this you most likely won't need dynamic variables, even if
 you need to start changing global variable values later on.


​Yep, I should do that.​




 Hope that helps,


​Certainly.

-- 
Cecil Westerho
​f​

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

2014-07-09 Thread Cecil Westerhof
2014-07-09 4:19 GMT+02:00 Bob Hutchison hutch-li...@recursive.ca:


 On Jul 8, 2014, at 7:08 PM, Cecil Westerhof cldwester...@gmail.com
 wrote:

 2014-07-08 23:11 GMT+02:00 Bob Hutchison hutch-li...@recursive.ca:


 On Jul 8, 2014, at 9:40 AM, Cecil Westerhof cldwester...@gmail.com
 wrote:

  In Clojure you can define a local constant with let, but I need a
 variable (I think).
 
  I want to do the following. I have a function that checks several
 things. Every time an error is found I want to set the variable errors to:
  (concat errors new-error)
 
  Is this possible? Or is there a better way to do this?

 Here's a different take on your question, and a few comments about how
 I'd write that code. I don't think you need the atom -- kinda ugly and the
 reduce/map/filter family of sequence functions will take you a long way.

 ; This is not a predicate, so don't use the -p suffix (and in Clojure
 it's a ? normally)


 ​As I understood it (I am rewriting land of lisp to Clojure) that when a
 function returns a true/false state, that you then use the -p suffix. When
 returning () there are no errors. But I should use the ? then?


 You’re returning a list of errors. You can interpret that as a
 truthy/falsy kind of thing, in which case make sure you’re returning a nil
 for the no-error case. And use the ‘?’ in Clojure.


​That I do with:
(let [errors (atom ())]

I changed the name to 'error-in-datastruct?'.


By the way. The current function is only the start of the checks.​

 ​After the if I need to do several other checks also. So I think I do need
 the atom. But maybe I am mistaken. ;-)


 I thought maybe your checks would be a little more than that. That’s why I
 left the ‘reduce’ version in there. Just make the function that is applied
 by reduce more powerful, perhaps pull it out into a separate function
 rather than an inline anonymous function. This will work as long as all
 tests are performed on one object at a time.

 No matter what, I’d recommend not going using an atom if you can help it.


​I have my work cut out. But that is the best way to learn. :-D

-- 
Cecil Westerhof

-- 
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: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 9:39 GMT+02:00 Cecil Westerhof cldwester...@gmail.com:

 Or you could use a definition of look more like this, which uses println

 to print each item on its own line (not sure if you wanted to retain the
 parens or not, but both are easily doable).

 (defn look []
   (doseq [d [(describe-location *location* nodes)
  (describe-paths *location* edges)
  (describe-objects *location* objects
 *object-locations*)]]
 (println d)))


 ​That certainly looks better. The only problem is that the lines of the
 different calls are still printed as one. But rewriting to use strings
 would solve that problem. I just have to finish the book, to see if I can
 change the lists to strings.​



​Solved it without reverting to stings. See attachment. The only 'problem'
are the parentheses. How to get rid of those?

​


  - Al variables in land of lisp begin and end with an asterisk. As I

  understood it, you only do this for variables that can be changed. So
  I renamed some variables. Did I understand this correctly, or is the
  usage of asterisks for something else?

 The earmuffs convention is related to dynamic variables. All global
 variables are dynamic in Common Lisp, but that's not the case in
 Clojure. You're creating dynamic variables (by using :dynamic metadata
 in your defs) but I didn't notice anywhere where you're using this
 feature (i.e. no binding or set! forms). Long story short, I would use
 earmuffs if the variables are dynamic but not otherwise.


 ​I read a little about it. And no, I do not use dynamic binding. So I
 probably should use atoms. Is there a convention how to name atoms?​


​Got also rid of the dynamic variables.

-- 
Cecil Westerhof

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


land-of-lisp-text-game.clj
Description: Binary data


Re: [ANN] clojure-scheme - Compiling Clojure to Scheme to C

2014-07-09 Thread Dry Jin
By the way, how does Clojure-Scheme hand the Clojures's libraries over to 
Gambit-C?

2012년 3월 15일 목요일 오전 6시 8분 2초 UTC+9, Nathan Sorenson 님의 말:

 I've modified the output of the ClojureScript compiler to emit Scheme 
 code. At this point the core library is successfully compiled by Gambit 
 Scheme. A nice advantage of this is that Gambit compiles code via C, 
 meaning that stand-alone Clojure executables are now available for any 
 platform with a suitable gcc compiler!

 Gambit, notably, also compiles to iOS. Just recently I've confirmed that 
 Clojure's core library runs on the iPad simulator.

 There is a ton of yak-shaving required at this point---compilation 
 consists of a combination of shell commands, Clojure-interpreted commands 
 and Gambit-interpreted commands. Hopefully this will soon be streamlined.

 https://github.com/takeoutweight/clojure-scheme


-- 
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: Why clojure does not have pure lazy-evaluation like Haskell ?

2014-07-09 Thread Colin Fleming
True, but I think that's why he argues for a strict language which controls
side effects via monads, as Haskell does.


On 9 July 2014 07:18, Magnus Therning mag...@therning.org wrote:

 On Tue, Jul 08, 2014 at 08:39:30PM +0200, Colin Fleming wrote:
  I searched for this as well, and found this:
  http://www.cs.nott.ac.uk/~gmh/appsem-slides/peytonjones.ppt
 
  Purity is more important than, and quite independent of, laziness
 
  and
 
  The next ML will be pure, with effects only via monads.  The next
 Haskell
  will be strict, but still pure.

 In the same presentation he also says that laziness has forced Haskell
 to stay pure, and that

 Every call-by-value language has given into the siren call of side
 effects.

 So even if they are independent on the technical level one could say
 that they are dependent on a design/social level.

 /M

 --
 Magnus Therning  OpenPGP: 0xAB4DFBA4
 email: mag...@therning.org   jabber: mag...@therning.org
 twitter: magthe   http://therning.org/magnus

 Most software today is very much like an Egyptian pyramid with
 millions of bricks piled on top of each other, with no structural
 integrity, but just done by brute force and thousands of slaves.
  -- Alan Kay


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


How to use functions from clojure.contrib?

2014-07-09 Thread Pierre Masci
Hi, I am new to Clojure (about a week) so I might be missing something.

I want to use the (positions) 
http://clojuredocs.org/clojure_contrib/clojure.contrib.seq/positions function 
from clojure.contrib.seq.
I could simply copy its source, but I would prefer a more generic way of 
using functions form clojure.contrib.
This page http://clojure.github.io/clojure-contrib/ indicates that 
clojure.contrib is deprecated, but I could not find (positions) anywhere 
else.

What is a good solution to this problem?

-- 
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: Client side tools for Clojure web app (back end questions as well, especially Pedestal)

2014-07-09 Thread Jonathon McKitrick
My new project is coming along nicely already.  I'm currently using XHR
calls to populate atoms on the client side, which are then automatically
rendered into the DOM via Reagent components.  It's wonderful, so far.


--
Jonathon McKitrick


On Tue, Jul 8, 2014 at 3:37 PM, Ahmad Hammad a.f.ham...@gmail.com wrote:

 Brendan, could you please elaborate on how you handled client/server
 communication with a project using Reagent/Om?

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


-- 
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: How to use functions from clojure.contrib?

2014-07-09 Thread Andy Fingerhut
Pierre:

The link to the page Where did Clojure.Contrib Go on the page where you
noted that clojure.contrib is deprecated gives the names of current
modular contrib libraries that contain most or all of what *some* older
clojure.contrib libraries contained.

Unfortunately clojure.contrib.seq has no corresponding current library
listed on that page, and I am not aware of any other place that
functionality may have been copied to.

CrossClj [1] might make it possible to find a more modern library where the
function positions was copied to that you could use (enter positions in the
search box at the upper right of the page).  However, I suspect that method
will quickly reach a point of diminishing returns if all you want is that
one function -- copying it into your code isn't a bad idea.

[1] http://crossclj.info

Andy



On Wed, Jul 9, 2014 at 4:20 AM, Pierre Masci mas...@gmail.com wrote:

 Hi, I am new to Clojure (about a week) so I might be missing something.

 I want to use the (positions)
 http://clojuredocs.org/clojure_contrib/clojure.contrib.seq/positions 
 function
 from clojure.contrib.seq.
 I could simply copy its source, but I would prefer a more generic way of
 using functions form clojure.contrib.
 This page http://clojure.github.io/clojure-contrib/ indicates that
 clojure.contrib is deprecated, but I could not find (positions) anywhere
 else.

 What is a good solution to this problem?

 --
 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, visit https://groups.google.com/d/optout.


Re: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 10:38 GMT+02:00 Cecil Westerhof cldwester...@gmail.com:

 2014-07-09 9:39 GMT+02:00 Cecil Westerhof cldwester...@gmail.com:

 Or you could use a definition of look more like this, which uses println

 to print each item on its own line (not sure if you wanted to retain the
 parens or not, but both are easily doable).

 (defn look []
   (doseq [d [(describe-location *location* nodes)
  (describe-paths *location* edges)
  (describe-objects *location* objects
 *object-locations*)]]
 (println d)))


 ​That certainly looks better. The only problem is that the lines of the
 different calls are still printed as one. But rewriting to use strings
 would solve that problem. I just have to finish the book, to see if I can
 change the lists to strings.​



 ​Solved it without reverting to stings. See attachment. The only 'problem'
 are the parentheses. How to get rid of those?


​Solved that one also:
(defn look []
  (doseq [d (concat (describe-location @location nodes)
(describe-paths@location edges)
(describe-objects  @location objects object-locations))]
(apply println d)))

-- 
Cecil Westerhof

-- 
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: How to use functions from clojure.contrib?

2014-07-09 Thread Pierre Masci
Thank you Andy, that's exactly the answer I needed.
I thought I might be missing the right place where to look, because I'm 
new to the ecosystem.
http://crossclj.info 
http://www.google.com/url?q=http%3A%2F%2Fcrossclj.infosa=Dsntz=1usg=AFQjCNG-DyQUTVfpaTQKl0M8glmTtO-tMQ
 is 
a very good resource to know of.

I will copy-paste that function for now.

-- 
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] Grimoire: up to date Clojure web docs

2014-07-09 Thread Alex P
There's also a version of what you wrote (at least something very similar), 
where one can specify libraries he wants docs for and have it all running 
either locally or on some webserver: https://github.com/ifesdjeen/gizmo-cloc
Adds code snippets with highlights and lucene-backed search.

On Wednesday, July 2, 2014 1:34:38 AM UTC+2, Reid McKenzie wrote:

 Hey guys, 

 If you're like me while using clojure.repl/doc works for the most part 
 there are just times that you need to send someone a link to the 
 official docs and navigating the docstrings in the core Clojure 
 repository is a pain. 

 After several months of being frustrated that clojuredocs is out of 
 date, I finally sat down and built an alternative which I'm pleased to 
 present here: http://www.arrdem.com/grimoire/ 

 Grimoire is still alpha and subject to change, especially with regards 
 to the example contribution process which needs streamlining beyond the 
 current click a link, edit on github and submit a PR. 

 I'd like to give a shout out to César for porting clojure.repl/source 
 into the doc generation script and to Nicola for his random usability 
 criticisms. 

 Reid McKenzie 


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


[ANN] Cats: category theory abstractions library for clojure(script).

2014-07-09 Thread Andrey Antukh
Hello everyone!

I just wanted to announce cats: category theory abstractions library for
clojure(script).

Why another library?
You can see a list of differences with existing libraries here:
http://niwibe.github.io/cats/#_why_another_library

Github: https://github.com/niwibe/cats
Documentation: http://niwibe.github.io/cats/

Best regards.
Andrey

-- 
Andrey Antukh - Андрей Антух - andrei.anto...@kaleidos.net / n...@niwi.be

http://www.niwi.be http://www.niwi.be/page/about/
https://github.com/niwibe

-- 
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: IllegalArgumentException when running core.async example

2014-07-09 Thread endbegin
Thanks!! That did it.

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


How to access record in a hashmap

2014-07-09 Thread Cecil Westerhof
When you have:
(def object-locations {
 'whiskey   'living-room
 'bucket'living-room
 'chain 'garden
 'frog  'garden
 'dummy 'nowhere
 'test  'nowhere
 })

You can retrieve the location of the bucket with:
(object-locations 'bucket)
and with:
('bucket object-locations)

Personally I find the first better, but ‘Clojure Programming' uses the
second possibility. What is the better way and why?

-- 
Cecil Westerhof

-- 
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: Proposing a new Clojure documentation system (in Clojure)

2014-07-09 Thread Edwin Watkeys


On Tuesday, May 6, 2014 10:39:47 AM UTC-4, Gregg Reynolds wrote:


 On Tue, May 6, 2014 at 4:53 AM, Phillip Lord philli...@newcastle.ac.uk 
 javascript: wrote:

Trivial things that I would like to be able to do that I cannot do (in a

 way which will be reliably interpreted).

  - Add hyperlinks
  - Distinguish between symbols (or names of vars) and normal words.
  - Distinguish between code (examples) and normal words
  - Have access to basic markdown style typography.


 I'm undecided on these.  They would obviously be useful, but on the other 
 hand minimalism has its virtues.  In the base case of reading code with a 
 plaintext editor, I usually find embedded doco with lots of markup annoying 
 and an impediment to code reading.  I think I'm inclined to favor keeping 
 markup out of code but I'm keeping an open mind about it.


Gregg,

I strongly opposed the introduction of case-sensitive identifiers in R6RS 
Scheme. Case-insensitive identifiers allow programmers to write comments 
and documentation that unambiguously refer to arguments and function names 
in ALL-CAPS. As a bonus, a sentence need never begin with a capital letter, 
even if one is using something like back-ticks to indicate monospaced type, 
because `All-caps` is an equally valid representation. There are legitimate 
reasons to embrace case-sensitive identifiers, but the happy interplay 
between pre-R5RS source code and the written word was lost.

In Clojure doc strings, I either pretend that identifiers are 
case-insensitive or use back-ticks and try very hard not to start sentences 
with lower-case identifiers. Regarding code itself, I tend to use all-caps 
identifiers for macro arguments, another common Scheme (and Lisp?) 
convention, to make it more clear what's going on during quasi-quoting.

Edwin

-- 
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: How to access record in a hashmap

2014-07-09 Thread Thomas Heller
Short and simple answer: NullPointerException

(def object-locations nil)

(object-locations 'bucket) will throw
('bucket object-locations) = nil

HTH,
/thomas

On Wednesday, July 9, 2014 3:48:53 PM UTC+2, Cecil Westerhof wrote:

 When you have:
 (def object-locations {
  'whiskey   'living-room
  'bucket'living-room
  'chain 'garden
  'frog  'garden
  'dummy 'nowhere
  'test  'nowhere
  })

 You can retrieve the location of the bucket with:
 (object-locations 'bucket)
 and with:
 ('bucket object-locations)

 Personally I find the first better, but ‘Clojure Programming' uses the 
 second possibility. What is the better way and why?

 -- 
 Cecil Westerhof 


-- 
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: How to access record in a hashmap

2014-07-09 Thread Thomas Heller
Oh and its rare (outside of macros) to use symbols like that. Usually you'd
use keywords.

(def object-locations
  {:whiskey :living-room})


On Wed, Jul 9, 2014 at 5:03 PM, Thomas Heller th.hel...@gmail.com wrote:

 Short and simple answer: NullPointerException

 (def object-locations nil)

 (object-locations 'bucket) will throw
 ('bucket object-locations) = nil

 HTH,
 /thomas

 On Wednesday, July 9, 2014 3:48:53 PM UTC+2, Cecil Westerhof wrote:

 When you have:
 (def object-locations {
  'whiskey   'living-room
  'bucket'living-room
  'chain 'garden
  'frog  'garden
  'dummy 'nowhere
  'test  'nowhere
  })

 You can retrieve the location of the bucket with:
 (object-locations 'bucket)
 and with:
 ('bucket object-locations)

 Personally I find the first better, but ‘Clojure Programming' uses the
 second possibility. What is the better way and why?

 --
 Cecil Westerhof

  --
 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/4KAuyAs34-s/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.


-- 
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: How to access record in a hashmap

2014-07-09 Thread Cecil Westerhof
2014-07-09 17:03 GMT+02:00 Thomas Heller th.hel...@gmail.com:

 Short and simple answer: NullPointerException

 (def object-locations nil)

 (object-locations 'bucket) will throw
 ('bucket object-locations) = nil


​That is interesting.​

​Not a problem, because it will never be ​nil, but always a HashMap. But
better save as sorry. I will change it.



 On Wednesday, July 9, 2014 3:48:53 PM UTC+2, Cecil Westerhof wrote:

 When you have:
 (def object-locations {
  'whiskey   'living-room
  'bucket'living-room
  'chain 'garden
  'frog  'garden
  'dummy 'nowhere
  'test  'nowhere
  })

 You can retrieve the location of the bucket with:
 (object-locations 'bucket)
 and with:
 ('bucket object-locations)

 Personally I find the first better, but ‘Clojure Programming' uses the
 second possibility. What is the better way and why?


-- 
Cecil Westerhof

-- 
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: How to access record in a hashmap

2014-07-09 Thread Cecil Westerhof
2014-07-09 17:18 GMT+02:00 Thomas Heller th.hel...@gmail.com:

 Oh and its rare (outside of macros) to use symbols like that. Usually
 you'd use keywords.

 (def object-locations
   {:whiskey :living-room})


​It is from 'Land of Lisp'. The symbols are printed. Or is it possible to
print the keyword without the :?



 On Wed, Jul 9, 2014 at 5:03 PM, Thomas Heller th.hel...@gmail.com wrote:

 Short and simple answer: NullPointerException

 (def object-locations nil)

 (object-locations 'bucket) will throw
 ('bucket object-locations) = nil

 HTH,
 /thomas

 On Wednesday, July 9, 2014 3:48:53 PM UTC+2, Cecil Westerhof wrote:

 When you have:
 (def object-locations {
  'whiskey   'living-room
  'bucket'living-room
  'chain 'garden
  'frog  'garden
  'dummy 'nowhere
  'test  'nowhere
  })

 You can retrieve the location of the bucket with:
 (object-locations 'bucket)
 and with:
 ('bucket object-locations)

 Personally I find the first better, but ‘Clojure Programming' uses the
 second possibility. What is the better way and why?


-- 
Cecil Westerhof

-- 
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: How to access record in a hashmap

2014-07-09 Thread Timothy Baldridge
(name :foo)

will return the name as a string

(symbol (name :foo))

Converts the name of the keyword to a symbol


On Wed, Jul 9, 2014 at 9:28 AM, Cecil Westerhof cldwester...@gmail.com
wrote:

 2014-07-09 17:18 GMT+02:00 Thomas Heller th.hel...@gmail.com:

 Oh and its rare (outside of macros) to use symbols like that. Usually
 you'd use keywords.

 (def object-locations
   {:whiskey :living-room})


 ​It is from 'Land of Lisp'. The symbols are printed. Or is it possible to
 print the keyword without the :?



 On Wed, Jul 9, 2014 at 5:03 PM, Thomas Heller th.hel...@gmail.com
 wrote:

 Short and simple answer: NullPointerException

 (def object-locations nil)

 (object-locations 'bucket) will throw
 ('bucket object-locations) = nil

 HTH,
 /thomas

 On Wednesday, July 9, 2014 3:48:53 PM UTC+2, Cecil Westerhof wrote:

 When you have:
 (def object-locations {
  'whiskey   'living-room
  'bucket'living-room
  'chain 'garden
  'frog  'garden
  'dummy 'nowhere
  'test  'nowhere
  })

 You can retrieve the location of the bucket with:
 (object-locations 'bucket)
 and with:
 ('bucket object-locations)

 Personally I find the first better, but ‘Clojure Programming' uses the
 second possibility. What is the better way and why?


 --
 Cecil Westerhof

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




-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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: How to access record in a hashmap

2014-07-09 Thread Thomas Heller
Don't know Land of Lisp, but if you print it you can use (name :whiskey) to
get whiskey (as a String), also works on (name 'whiskey).


On Wed, Jul 9, 2014 at 5:28 PM, Cecil Westerhof cldwester...@gmail.com
wrote:

 2014-07-09 17:18 GMT+02:00 Thomas Heller th.hel...@gmail.com:

 Oh and its rare (outside of macros) to use symbols like that. Usually
 you'd use keywords.

 (def object-locations
   {:whiskey :living-room})


 ​It is from 'Land of Lisp'. The symbols are printed. Or is it possible to
 print the keyword without the :?



 On Wed, Jul 9, 2014 at 5:03 PM, Thomas Heller th.hel...@gmail.com
 wrote:

 Short and simple answer: NullPointerException

 (def object-locations nil)

 (object-locations 'bucket) will throw
 ('bucket object-locations) = nil

 HTH,
 /thomas

 On Wednesday, July 9, 2014 3:48:53 PM UTC+2, Cecil Westerhof wrote:

 When you have:
 (def object-locations {
  'whiskey   'living-room
  'bucket'living-room
  'chain 'garden
  'frog  'garden
  'dummy 'nowhere
  'test  'nowhere
  })

 You can retrieve the location of the bucket with:
 (object-locations 'bucket)
 and with:
 ('bucket object-locations)

 Personally I find the first better, but ‘Clojure Programming' uses the
 second possibility. What is the better way and why?


 --
 Cecil Westerhof

 --
 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/4KAuyAs34-s/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.


-- 
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: How to access record in a hashmap

2014-07-09 Thread Cecil Westerhof
2014-07-09 17:32 GMT+02:00 Timothy Baldridge tbaldri...@gmail.com:

 (name :foo)

 will return the name as a string

 (symbol (name :foo))

 Converts the name of the keyword to a symbol


​It is not even necessary. I changed to keywords. The code uses:
`(You see a ~obj on the floor.)

And it is displayed as:
You see a whiskey on the floor.
You see a bucket on the floor.

Maybe it does not work in all cases: so I need to do some testing.
​Let change the rest also to keywords.​



 On Wed, Jul 9, 2014 at 9:28 AM, Cecil Westerhof cldwester...@gmail.com
 wrote:

 2014-07-09 17:18 GMT+02:00 Thomas Heller th.hel...@gmail.com:

 Oh and its rare (outside of macros) to use symbols like that. Usually
 you'd use keywords.

 (def object-locations
   {:whiskey :living-room})


 ​It is from 'Land of Lisp'. The symbols are printed. Or is it possible to
 print the keyword without the :?



 On Wed, Jul 9, 2014 at 5:03 PM, Thomas Heller th.hel...@gmail.com
 wrote:

 Short and simple answer: NullPointerException

 (def object-locations nil)

 (object-locations 'bucket) will throw
 ('bucket object-locations) = nil

 HTH,
 /thomas

 On Wednesday, July 9, 2014 3:48:53 PM UTC+2, Cecil Westerhof wrote:

 When you have:
 (def object-locations {
  'whiskey   'living-room
  'bucket'living-room
  'chain 'garden
  'frog  'garden
  'dummy 'nowhere
  'test  'nowhere
  })

 You can retrieve the location of the bucket with:
 (object-locations 'bucket)
 and with:
 ('bucket object-locations)

 Personally I find the first better, but ‘Clojure Programming' uses the
 second possibility. What is the better way and why?


-- 
Cecil Westerhof

-- 
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: How to access record in a hashmap

2014-07-09 Thread Cecil Westerhof
2014-07-09 17:50 GMT+02:00 Cecil Westerhof cldwester...@gmail.com:

 2014-07-09 17:32 GMT+02:00 Timothy Baldridge tbaldri...@gmail.com:

 (name :foo)

 will return the name as a string

 (symbol (name :foo))

 Converts the name of the keyword to a symbol


 ​It is not even necessary. I changed to keywords. The code uses:
 `(You see a ~obj on the floor.)

 And it is displayed as:
 You see a whiskey on the floor.
 You see a bucket on the floor.

 Maybe it does not work in all cases: so I need to do some testing.
 ​Let change the rest also to keywords.​


​It seems to work. The only 'problem' is that I​

​need to use:
(pickup :bucket)
instead of:
(pickup 'bucket)​

But that is only temporary, because there will be an optimisation later on.



 On Wed, Jul 9, 2014 at 9:28 AM, Cecil Westerhof cldwester...@gmail.com
 wrote:

 2014-07-09 17:18 GMT+02:00 Thomas Heller th.hel...@gmail.com:

 Oh and its rare (outside of macros) to use symbols like that. Usually
 you'd use keywords.

 (def object-locations
   {:whiskey :living-room})


 ​It is from 'Land of Lisp'. The symbols are printed. Or is it possible
 to print the keyword without the :?



 On Wed, Jul 9, 2014 at 5:03 PM, Thomas Heller th.hel...@gmail.com
 wrote:

 Short and simple answer: NullPointerException

 (def object-locations nil)

 (object-locations 'bucket) will throw
 ('bucket object-locations) = nil

 HTH,
 /thomas

 On Wednesday, July 9, 2014 3:48:53 PM UTC+2, Cecil Westerhof wrote:

  When you have:
 (def object-locations {
  'whiskey   'living-room
  'bucket'living-room
  'chain 'garden
  'frog  'garden
  'dummy 'nowhere
  'test  'nowhere
  })

 You can retrieve the location of the bucket with:
 (object-locations 'bucket)
 and with:
 ('bucket object-locations)

 Personally I find the first better, but ‘Clojure Programming' uses
 the second possibility. What is the better way and why?


-- 
Cecil Westerhof

-- 
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: Land of lisp to Clojure

2014-07-09 Thread John Mastro
Cecil Westerhof cldwester...@gmail.com wrote:
 I read a little about it. And no, I do not use dynamic binding. So I
 probably should use atoms. Is there a convention how to name atoms?

Nope, none that I've come across anyway. Dynamic variables can have very
surprising effects if you're not aware you're dealing with them. This is
more of an issue in Common Lisp than in Clojure because in CL you can
rebind both dynamic and lexical variables with `let`, whereas in Clojure
`let` always produces a lexical binding (`binding` creates dynamic
bindings). With Atoms, the worst that happens is you forget to deref one
and you get an NPE or whatever.

Land of Lisp sounds like a fun book. My books to read stack is pretty
massive but I'll get to it eventually.

All the best,

John

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


An Averaging function

2014-07-09 Thread Stephen Feyrer
Hi,

I tried to create the function below in a Lighttable instarepl.  In lieu of
any better idea for formatting, thestatements below indicate
instarepl output.

(defn avged ([x]
((def sumed (reduce + x))  10 
(def counted (count x))  4 
(def result (/ sumed counted))  5/2 
result
)))

(avged [1 2 3 4])  java.lang.ClassCastException: java.lang.Long cannot be
cast to clojure.lang.IFn
Var.java:392 clojure.lang.Var.fn
Var.java:423 clojure.lang.Var.invoke
(Unknown Source) user/avged 

The objective of this function is just a learning exercise.

I have three questions:

1. Why doesn't it work, return a value?

2. What does the error message mean?  and seeing this or similar again, how
do I investigate to get a meaningful Clojure solution?

3.  Code Style, what can I do to improve readability and form?


Thanks.

--
Stephen Feyrer.

-- 
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: An Averaging function

2014-07-09 Thread Sam Ritchie
About code style, don't do defs inside of a function - this binds them 
inside the entire namespace, so your values are escaping and persisting 
when you just want locals. Use let:


(defn averaged [x]
  (let [summed (reduce + x)
 counted (count x)]
(/ summed counted)))

That function actually does work, by the way. I suspect that farther up 
in your lighttable/repl session you bound avged to a number, like (def 
avged 10).

Stephen Feyrer mailto:stephen.fey...@gmail.com
July 9, 2014 at 6:48 PM
Hi,

I tried to create the function below in a Lighttable instarepl.  In 
lieu of any better idea for formatting, the   statements below 
indicate instarepl output.


(defn avged ([x]
((def sumed (reduce + x))  10 
(def counted (count x))  4 
(def result (/ sumed counted))  5/2 
result
)))

(avged [1 2 3 4])  java.lang.ClassCastException: java.lang.Long 
cannot be cast to clojure.lang.IFn

Var.java:392 clojure.lang.Var.fn
Var.java:423 clojure.lang.Var.invoke
(Unknown Source) user/avged 

The objective of this function is just a learning exercise.

I have three questions:

1. Why doesn't it work, return a value?

2. What does the error message mean?  and seeing this or similar 
again, how do I investigate to get a meaningful Clojure solution?


3.  Code Style, what can I do to improve readability and form?


Thanks.

--
Stephen Feyrer.
--
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 
mailto:clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Sam Ritchie (@sritchie)
Paddleguru Co-Founder
703.863.8561
www.paddleguru.com http://www.paddleguru.com/
Twitter http://twitter.com/paddleguru// Facebook 
http://facebook.com/paddleguru


--
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: An Averaging function

2014-07-09 Thread Lee Spector

On Jul 9, 2014, at 8:48 PM, Stephen Feyrer stephen.fey...@gmail.com wrote:

 Hi,
 
 I tried to create the function below in a Lighttable instarepl.  In lieu of 
 any better idea for formatting, thestatements below indicate instarepl 
 output.
 
 (defn avged ([x]
 ((def sumed (reduce + x))  10 
 (def counted (count x))  4 
 (def result (/ sumed counted))  5/2 
 result
 )))
 
 (avged [1 2 3 4])  java.lang.ClassCastException: java.lang.Long cannot be 
 cast to clojure.lang.IFn
 Var.java:392 clojure.lang.Var.fn
 Var.java:423 clojure.lang.Var.invoke
 (Unknown Source) user/avged 
 
 The objective of this function is just a learning exercise.
 
 I have three questions:
 
 1. Why doesn't it work, return a value?

Hi Stephen,

The main reason it doesn't work is that the expression after the parameter list 
[x] is a list and will be interpreted as a function call, with the function 
being whatever is returned from the first thing in the list -- which in this 
case is the def sumed definition, which returns the defined var.

You could patch (not recommended!) this by adding do to the beginning of that 
list:

(defn avged 
  ([x]
(do 
  (def sumed (reduce + x)) 
  (def counted (count x))
  (def result (/ sumed counted)) 
  result)))

That will work, but it's not idiomatic clojure -- it is almost never idiomatic 
clojure to have a def or defn within another defn. Also, you've used the syntax 
that allows for multiple arglist/body pairs, although you only need one so the 
extra layer of parentheses isn't necessary.

Here's how I might write it somewhat more idiomatically:

(defn avged 
 [x]
 (let [sumed (reduce + x)
   counted (count x)
   result (/ sumed counted)]
   result))

= (avged [1 2 3 4])
5/2
= (float (avged [1 2 3 4]))
2.5


 
 2. What does the error message mean?  and seeing this or similar again, how 
 do I investigate to get a meaningful Clojure solution?

I think it means it's trying to call the value of sumed as a function. I'll 
leave it to others to suggest ways of understanding Clojure error messages (and 
just note for any of those others who have the ability to do something about 
this that it sure would be great to be able to get stack backtraces with values 
of locals regardless of IDE etc.).

 3.  Code Style, what can I do to improve readability and form?

Myself, I'd probably do it without any variables at all, and name everything 
more meaningfully, e.g.:

(defn average-numbers
  Returns the average of the provided numbers.
  [numbers]
  (/ (reduce + numbers)
 (count numbers)))

= (average-numbers [1 2 3 4])
5/2

 -Lee

-- 
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: An Averaging function

2014-07-09 Thread Lee Spector

On Jul 9, 2014, at 9:31 PM, Lee Spector lspec...@hampshire.edu wrote:
 You could patch (not recommended!) this by adding do to the beginning of 
 that list:

Or -- I now see, instead of adding the do you could just remove the outermost 
parentheses after the parameter list. But as Sam and I said this is a bad way 
to go anyway -- you want to avoid the nested defs.

 -Lee

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