Re: An Averaging function

2014-07-09 Thread Lee Spector
On Jul 9, 2014, at 9:31 PM, Lee Spector 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

Re: An Averaging function

2014-07-09 Thread Lee Spector
On Jul 9, 2014, at 8:48 PM, Stephen Feyrer wrote: > 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 coun

Re: An Averaging function

2014-07-09 Thread Sam Ritchie
About code style, don't do "def"s 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 functi

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

Re: Land of lisp to Clojure

2014-07-09 Thread John Mastro
Cecil Westerhof 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 t

Re: How to access record in a hashmap

2014-07-09 Thread Cecil Westerhof
2014-07-09 17:50 GMT+02:00 Cecil Westerhof : > 2014-07-09 17:32 GMT+02:00 Timothy Baldridge : > > (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:

Re: How to access record in a hashmap

2014-07-09 Thread Cecil Westerhof
2014-07-09 17:32 GMT+02:00 Timothy Baldridge : > (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 a

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 wrote: > 2014-07-09 17:18 GMT+02:00 Thomas Heller : > > Oh and its rare (outside of macros) to use symbols like

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 wrote: > 2014-07-09 17:18 GMT+02:00 Thomas Heller : > > Oh and its rare (outside of macros) to use symbols like that. Usually >> you'

Re: How to access record in a hashmap

2014-07-09 Thread Cecil Westerhof
2014-07-09 17:18 GMT+02:00 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}) > ​It is from 'Land of Lisp'. The symbols are printed. Or is it possible to print the keyword without the

Re: How to access record in a hashmap

2014-07-09 Thread Cecil Westerhof
2014-07-09 17:03 GMT+02:00 Thomas Heller : > 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. Bu

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 wrote: > Short and simple answer: NullPointerException > > (def object-locations nil) > > (object-locations '

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 'livin

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

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:

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 grou

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

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 Wedne

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 is a very good res

Re: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 10:38 GMT+02:00 Cecil Westerhof : > 2014-07-09 9:39 GMT+02:00 Cecil Westerhof : > > 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). >>

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 ha

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

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) function from clojure.contrib.seq. I could simply copy its source, but I would prefer a more generic way of using function

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

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

Re: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 9:39 GMT+02:00 Cecil Westerhof : > 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-

Re: Local variable

2014-07-09 Thread Cecil Westerhof
2014-07-09 4:19 GMT+02:00 Bob Hutchison : > > On Jul 8, 2014, at 7:08 PM, Cecil Westerhof > wrote: > > 2014-07-08 23:11 GMT+02:00 Bob Hutchison : > >> >> On Jul 8, 2014, at 9:40 AM, Cecil Westerhof >> wrote: >> >> > In Clojure you can define a local constant with let, but I need a >> variable (I

Re: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 5:30 GMT+02:00 John Mastro : > Cecil Westerhof 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 in

Re: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 5:11 GMT+02:00 Timothy Baldridge : > 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.

Re: Land of lisp to Clojure

2014-07-09 Thread Cecil Westerhof
2014-07-09 2:24 GMT+02:00 Bruce Wang : > 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 "Cloj