Re: newbie question regarding maps

2012-09-27 Thread Mond Ray
Thanks for the support and especially the examples.  I will be back when I 
bump into the next level of complexity ;-)

On Monday, 24 September 2012 12:04:42 UTC+2, Mond Ray wrote:
>
> I am playing around with maps and using wish lists as a learning tool. I 
> have a list of items in wish lists like this:
>
> user=> items
> [{:name "Item 1", :cost 20.0} {:name "Item 2", :cost 40.0}]
>
> user=> wiggle-items
> [{:name "Wiggle 1", :cost 20.0} {:name "Wiggle 2", :cost 40.0} [:name 
> "Item 3" :cost 10.0]]
>
> user=> (def wish-lists [
> {:name "WL1" :items items}
> {:name "WL2" :items wiggle-items}
> ]
> )
> #'user/wish-lists
>
> user=> wish-lists
> [{:name "WL1", :items [{:name "Item 1", :cost 20.0} {:name "Item 2", :cost 
> 40.0}]} {:name "WL2", :items [{:name "Wiggle 1", :cost 20.0} {:name "Wiggle 
> 2", :cost 40.0} [:name "Item 3" :cost 10.0]]}]
>
> ---
>
> I now want to add an item to one of the Wish Lists but am struggling with 
> assoc and assoc-in (which seems to be the one I need).
>
> ---
>
> user=> (def new-wi (conj wiggle-items [ :name "Item 3" :cost 10.0 ]))
>
> #'user/new-wi
>
> user=> (assoc-in wish-lists [:name "WL1"] [:name "WL1" :items new-wi])
> IllegalArgumentException Key must be integer 
> clojure.lang.APersistentVector.assoc (APersistentVector.java:312)
>
>
> As you can see the REPL gives me an error stating that the keys must be 
> Integers. Is that right?  Or is my call process faulty?
>
> Thanks in advance for your support.
>
>
> ray
>

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

Re: Does Clojure support efficient coroutines?

2012-09-27 Thread nicolas.o...@gmail.com
Depending of the code they have to write, you can walk their code at
compile time and transform it to
monadic normal form or CPS style, which would allow to do what you want.

I would tend to think that with a lot of threads you will win with
closures and not native threads.
And would only a few threads, threads would be faster.

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


Re: Core.logic performance of looping over a list with tabling

2012-09-27 Thread Reinout Stevens


Op woensdag 26 september 2012 22:21:26 UTC+2 schreef David Nolen het 
volgende:
>
> On Wed, Sep 26, 2012 at 8:20 AM, Reinout Stevens 
> 
> > wrote:
>
>> Hi,
>>
>>
>> I'm the author of a DSL that allows reasoning over paths throughout 
>> graphs using core.logic ( https://github.com/ReinoutStevens/damp.qwal ). 
>> We noticed that for larger graphs performance became horribly slow, even 
>> though there is no apparent reason why it should be. First investigations 
>> lead me to believe tabling was the issue. We use tabling to prevent 
>> infinite loops due to cycles in the graph. After writing a small testcase 
>> that exhibits the described problems I've noticed that it is a combination 
>> of tabling and looping over a list.
>>
>> In the test case we construct a linear graph (so: a graph where each node 
>> has a single successor). We want to asser that there exists a path from the 
>> start to the end node. This is done by using the logical rule trans 
>> [graph current next], which given a graph and the current node binds next to 
>> the possible successors. We write this query in three different ways. 
>> First, we try to succeed the goal trans as many times as needed, until we 
>> end up in the end state. Next, we do the same but tabling our loop. This 
>> prevents looping in case our graph would contain a cycle (in this case, 
>> there is no such cycle). Finally, instead of directly proving trans, we 
>> prove a list of goals. This list contains a single goal (trans). This last 
>> scenario runs much slower than the previous two, even though I don't see a 
>> large difference with the first two scenarios.
>>
>> In attachment the code of our test case. There are 3 functions at the 
>> end, each implementing one of the described scenarios. Note the difference 
>> between solve-goal and solve-goals.
>>
>> Any pointers how to solve the issue, or work around it are appreciated
>>
>
> Thanks for the feedback, I've created a ticket 
> http://dev.clojure.org/jira/browse/LOGIC-57
>
> I will look into it. What version of core.logic are you using? Out of 
> curiosity did you experiment with a profiler at all and perhaps collected 
> some clues?
>
> David 
>
>
That would be version '0.7.5'
I have used JVisualVM to look into it, but didn't find anything useful.
 

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

Re: Clojure : a good start for non-programmers?

2012-09-27 Thread Geoffrey
I agree greg r's approach, tooling is very important when starting, 
racket comes ready to roll.


On 27/09/12 06:59, greg r wrote:


I would go with the book "Simply Scheme, Introducing Computer Science" 
by Harvey and Wright.

Install the Racket system on your computer, and have at it.

http://racket-lang.org/

Once you come up to speed on Scheme, you will have no trouble with 
core Clojure.
But if you venture in the the Java interop, you will have to 
understand object oriented programming.
A good resource for Java is "Objects First with Java, A Practical 
Introduction using BlueJ".


Also you can want watch the Brian Harvey lectures on functional 
programming on Youtube.

Good luck, functional programming is challenging and fun.

Regards,
Greg
--
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 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


Re: comp inside macro

2012-09-27 Thread sailormoo...@gmail.com
Solved. Thanks ^o^

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

Re: clojure - "diff" of sequence's

2012-09-27 Thread Alex Shabanov
Thanks!
Looks like subvec is the best one for the kind of task (i.e. when 
preserving element order matters) - if the sequences are finite, non-lazy 
collections - e.g. lists or vectors.

среда, 26 сентября 2012 г., 15:16:49 UTC+4 пользователь Niels van Klaveren 
написал:
>
> There's several different options, best read up on the differences between 
> these differences in the docstrings:
>
> (remove (set b) a)
>
> (clojure.set/difference (set b) (set a))
>
> (last (clojure.data/diff a b))
>
>
> On Wednesday, September 26, 2012 10:46:57 AM UTC+2, Alex Shabanov wrote:
>>
>> Good day,
>>
>> There is a function FOO that receives two sequences: say, A and B. There 
>> is an absolute guarantee that sequence B is received from sequence A by 
>> applying next to it N times, e.g. B == (next (next (next... A) | A.
>> What is the fastest way to return sequence C from the function FOO that 
>> contains all the heading entries in sequence A in the same order, that are 
>> not included in B?
>>
>> Example: A == [1 2 3 4], B == [3 4], (FOO A B) -> [1 2]
>>
>> I feel it is impossible to introduce a fast O(N) solution when A and B 
>> just sequences, and if it is so, what *standard* clojure data structures 
>> that preserves the order of elements can be used for doing so?
>>
>> BR,
>> Alex
>>
>

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

Questions regarding do form

2012-09-27 Thread arekanderu
Hello all,

I am new to clojure and I have two questions about do and the way it should 
be used.

*Question 1: Which of the following two functions is more idiomatic and 
why? Both functions produce the same result.*


(defn my-fn [java-object]
  (. java-object firstFunc)
  (. java-object secondFunc)
  (. java-object thirdFunc)
  java-object)



(defn my-fn [java-object]
  (do (. java-object firstFunc)
(. java-object secondFunc )
(. java-object thirdFunc )
java-object))


*Question 2: Again, which one is more idiomatic and why? Both functions 
produce the same result.*
*
*

(defn my-fn [java-object bar]
  (let [bar-bar (. java-object getSomething)
_   (if (not (is-bar? bar))
  (. java-object (setSomething bar-bar)))]
java-object))



(defn my-fn [java-object bar]
  (let [bar-bar (. java-object getSomething)]
(do 
  (if (not (is-bar? bar))
(. java-object (setSomething bar-bar)))
 java-object)))



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

Re: Clojure : a good start for non-programmers?

2012-09-27 Thread CA
1. Yes , there is no language that is harder to learn than any other.
Clojure happens to be especially newbie friendly.
2. Start with getting yourself familiar with the clojure development
environment. These days the best options are Emacs+Nrepl or Eclipse
+CounterClockwise. When it is up download the clojure cheat sheet and
try to understand what those functions are doing.
3.That is for you too decide.

On Sep 24, 8:11 am, "Gregorius R."  wrote:
> Hello Clojurists!
>
> I'm a person in middle age (you know, too old to rock'n'roll, to young to
> die) and would like to programm but starting with functional programming.
> Regarding this i have some questions:
>
> is clojure a good start to learn programming?
> which (prerfer free online) is a good tut to start?
> am i to old for this stuff?
>
> thnx in advance for all responses
> Greg

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


Re: Light Table Playground got a lot more useful.

2012-09-27 Thread humblepie
For the life of me I can figure out the key binding for the Cmd key. Can 
someone help?

On Monday, July 9, 2012 6:27:26 PM UTC-7, Chris Granger wrote:
>
> Hey folks, 
>
> In case you missed it via other channels, the Light Table Playground 
> can now hook into your own projects! 
>
> http://www.chris-granger.com/2012/07/09/light-table-playgrounds-level-up/ 
>
> Take her for a spin :D 
>
> Cheers, 
> Chris.

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

Re: Clojure : a good start for non-programmers?

2012-09-27 Thread Ian

On 26/09/2012 20:04, Jim - FooBar(); wrote:

On 26/09/12 17:10, Ian wrote:
If you want to start with a functional language, then I would start 
with Erlang or Haskell, rather than Closure.


Closure is a great language, but it runs on the Java VM, and you are 
expected to know and understand Java data structures. I found 
learning both Closure and Java together was heavy going because it 
was documented in two places.


The language is called "Clojure" not "Closure"
sorry for nitpicking but you did it 3 times... :-)

Jim


Mea culpa. Mea maxima culpa.

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


Re: Questions regarding do form

2012-09-27 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:

I am new to clojure and I have two questions about do and the way it should 
> be used.
>
> *Question 1: Which of the following two functions is more idiomatic and 
> why? Both functions produce the same result.*
>
> 
> (defn my-fn [java-object]
>   (. java-object firstFunc)
>   (. java-object secondFunc)
>   (. java-object thirdFunc)
>   java-object)
> 
>

The first because defn includes an implicit do. So the second example is 
actually (do (do ...)).

In this case you could also use doto:

(defn my-fn
  [pojo]
  (doto pojo
.firstFunc
.secondFunc
.thirdFunc))

 

> *Question 2: Again, which one is more idiomatic and why? Both functions 
> produce the same result.*
> *
> *
> 
> (defn my-fn [java-object bar]
>   (let [bar-bar (. java-object getSomething)
> _   (if (not (is-bar? bar))
>   (. java-object (setSomething bar-bar)))]
> java-object))
> 
>
> 
> (defn my-fn [java-object bar]
>   (let [bar-bar (. java-object getSomething)]
> (do 
>   (if (not (is-bar? bar))
> (. java-object (setSomething bar-bar)))
>  java-object)))
> 
>

The third:

(defn my-fn
  [pojo bar]
  (let [bar-bar (.getSomething pojo)]
(when-not (is-bar? bar)
  (.setSomething pojo bar-bar))
pojo)))

let also (just like defn) includes an implicit do for the body.

Hope this helps.

Kind regards
Meikel
 

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

Re: Does Clojure support efficient coroutines?

2012-09-27 Thread Timothy Baldridge
You have several options here:

1) Agents
2) Something like actors (my implementation is here
https://github.com/halgari/microactors/blob/master/src/microactors/core.clj
 )
4) Dataflow using agents (or fork/join perhaps)
3) CPS (as mentioned)

Perhaps a bit more explanation of what you're trying to accomplish might
help?

Timothy

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

Re: Clojure : a good start for non-programmers?

2012-09-27 Thread Giuliani Sanches
Hi Gregorious,

I will show you the track that i'm followin to learn Clojure. I'm a 
programmer since 99, so maybe this does not apply for you, but can be a 
good reference:

1- http://blackstag.com/blog.posting?id=5 (for me was a good starting point)
2 - http://java.ociweb.com/mark/clojure/article.html (Some concepts started 
to hurt my brain, but i'm going forward, waiting for the next step)
3 - Clojure Programmin (O'Reilly)
4 - Programming Clojure (The Pragmatic Bookshelf)

Between steps 3 and 4 i will read some tutorial about Noir like the one 
here: http://yogthos.net/blog/22-Noir+tutorial+-+part+1

;)

On Wednesday, September 26, 2012 4:16:53 PM UTC-3, Hobson42 wrote:
>
> On 26/09/2012 20:04, Jim - FooBar(); wrote: 
> > On 26/09/12 17:10, Ian wrote: 
> >> If you want to start with a functional language, then I would start 
> >> with Erlang or Haskell, rather than Closure. 
> >> 
> >> Closure is a great language, but it runs on the Java VM, and you are 
> >> expected to know and understand Java data structures. I found 
> >> learning both Closure and Java together was heavy going because it 
> >> was documented in two places. 
> > 
> > The language is called "Clojure" not "Closure" 
> > sorry for nitpicking but you did it 3 times... :-) 
> > 
> > Jim 
> > 
> Mea culpa. Mea maxima culpa. 
>
>

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

Re: [ILC2012] CALL FOR PARTICIPATION

2012-09-27 Thread Grant Rettke
Same goes for ICFP:

http://icfpconference.org/icfp2012/accepted.html

On Thu, Sep 27, 2012 at 1:05 AM, Jianshi Huang  wrote:
> Just curious, why there are no Clojure speakers and papers?
>
> I think projects like cascalog, clojure.logic and light table are
> brilliant showcases for Lisp. The lightning talks session is still
> open for submissions.
>
> -- Forwarded message --
> From: KURODA Hisao 
> Date: Wed, Aug 8, 2012 at 5:47 PM
> Subject: [ILC2012] CALL FOR PARTICIPATION
> To: lisp-...@lispworks.com
>
>
>
> INTERNATIONAL LISP CONFERENCE 2012: Call for Participation
> ==
>
> The Association of Lisp Users (ALU) is pleased to announce ILC 2012, to be
> held in Kyoto, Japan October 21st-24th. Please make a note of the following
> important dates and events.
>
> 0.  Conference Home Page
> http://international-lisp-conference.org
>
> 1.  Conference Schedule Outline
> http://international-lisp-conference.org/2012/schedule.html.
>
> 2. Technical papers are currently being reviewed and speakers will be
> announced shortly:
> http://international-lisp-conference.org/2012/speakers.html
>
> 3. Registration:
> http://international-lisp-conference.org/2012/registration.html
>
> 4. Please reserve your hotels early, as availability is limited this time of
> the year in Kyoto:
> http://international-lisp-conference.org/2012/paypal-online.html#sec-2
>
> 5. We are proud to announce  following distinguished speakers:
> -- Mark Battyani: Successful Lisp Entrepreneur
> -- Christian Queinnec: Author of Lisp In Small Pieces
> -- Ikuo Takeuchi:  Renown Japanese Inventor of the TAK-function
> -- Eiiti Wada: Famous Japanese Lisp Guru -- Designer of Happy Hacking Keyboard
>
> ___
> Lisp Hug - the mailing list for LispWorks users
> lisp-...@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>
>
>
> --
> Jianshi Huang
>
> Co-founder and CTO at Maptia (maptia.com)
>
> LinkedIn: jianshi
> Twitter: @jshuang
> Github & Blog: http://huangjs.github.com/
>
> --
> 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



-- 
((λ (x) (x x)) (λ (x) (x x)))
http://www.wisdomandwonder.com/
ACM, AMA, COG, IEEE

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


Issues with round tripping and tagged literals

2012-09-27 Thread Brent Millare
When one needs to get clojure data passed around over some string carrying 
pipe, one would need to override the print-dup/print-method methods for 
non-roundtrippable objects like java.io.File. This modifies the public and 
functionally global namespace, which is not good practice. A recommended 
approach would be to define one's own print function like so

http://stackoverflow.com/questions/10005102/how-to-override-println-behavior-for-reference-types/10013247#10013247

However, this approach is leaky. Though in some other objects and it fails 
again. One might then provide default methods or Object methods that 
delegate back to print-method. This, however, doesn't work for collections 
since collections delegate only to clojure.core print methods and if you 
see a File in there, it won't use your methods. Therefore, coming back, the 
only way to make a truly non global modifying but complete printer, one 
would need to basically write their own version of 
clojure/src/clj/clojure/core_print.clj. A much larger task.

A couple of observations here:

1. It seems useful to be able to copy an existing multimethod (and its 
implementations) into another namespaced multimethod. Then one should be 
able to make incremental changes. This is analogous to copying someone's 
hashmap, and then using clojure.core/update-in to modify it for your use. 
The other person's hashmap is unmodified.

2. When reading in the strings that contain forms, we rely on the 
*data-readers* hashmap, which is a map from symbols to fns. One limitation 
with this approach is we can't match patterns, only concrete symbols. So 
phrased differently, currently it's not possible to call a fn on anything 
of the pattern #my.personal.namespace/ "clojure 
data literals", I realize that we need to be careful of what the reader can 
do in terms of parsing, but I feel it needs to be more flexible. An 
alternative approach would be to have the reader pass the valid symbol to a 
rebindable dispatch function. This may be too powerful, however, since 
parsing classnames and reserved tags wouldn't compose well in this 
situation. To perhaps strike a balance, one compromise would be to do this 
only for full qualified symbols. This way different people's tags and their 
implementations don't step on each other.

Yet another solution (which I am starting to like more as a write and is 
really more a convention then an implementation), would be to treat the 
tags conceptually not as a symbol, but as a namespace reference. Then one 
could print additional data (in the data literal part) that one could then 
dispatch off of. This has the advantage of not requiring modifications to 
the current implementation of tagged literals. I haven't seen many examples 
of tagged literals on the mailing list, but this requires some agreement 
about how we name our tags so that we don't step on each other.

So instead of

#my.namespace/someobject ["blah blah"]

we have

#my.namespace [:someobject "blah blah"]

Thoughts?

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

Re: clojurescript: *ns*, all-ns, ns-map, ns-publics, ns-* ?

2012-09-27 Thread Frank Siebenlist
Thanks Stuart - especially @namespaces is very helpful for understanding more 
about the resolution process.


On Sep 26, 2012, at 12:00 PM, Stuart Sierra  wrote:

> Some of this information exists in the CLJS compiler, although it's not 
> documented.
> 
> For example, the cljs.analyzer namespace has *cljs-ns* and `namespaces`. You 
> could examine these Vars at the Clojure (not ClojureScript) REPL.
> 
> Vars and namespaces do not exist at all in compiled CLJS code, so you can't 
> access them from CLJS. This is unlikely to change.
> -S
> 

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


Re: Questions regarding do form

2012-09-27 Thread arekanderu
Thank you Meikel for your so helpful replies.

On Thursday, September 27, 2012 4:19:44 PM UTC+3, Meikel Brandmeyer 
(kotarak) wrote:
>
> Hi,
>
> Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:
>
> I am new to clojure and I have two questions about do and the way it 
>> should be used.
>>
>> *Question 1: Which of the following two functions is more idiomatic and 
>> why? Both functions produce the same result.*
>>
>> 
>> (defn my-fn [java-object]
>>   (. java-object firstFunc)
>>   (. java-object secondFunc)
>>   (. java-object thirdFunc)
>>   java-object)
>> 
>>
>
> The first because defn includes an implicit do. So the second example is 
> actually (do (do ...)).
>
> In this case you could also use doto:
>
> (defn my-fn
>   [pojo]
>   (doto pojo
> .firstFunc
> .secondFunc
> .thirdFunc))
>
>  
>
>> *Question 2: Again, which one is more idiomatic and why? Both functions 
>> produce the same result.*
>> *
>> *
>> 
>> (defn my-fn [java-object bar]
>>   (let [bar-bar (. java-object getSomething)
>> _   (if (not (is-bar? bar))
>>   (. java-object (setSomething bar-bar)))]
>> java-object))
>> 
>>
>> 
>> (defn my-fn [java-object bar]
>>   (let [bar-bar (. java-object getSomething)]
>> (do 
>>   (if (not (is-bar? bar))
>> (. java-object (setSomething bar-bar)))
>>  java-object)))
>> 
>>
>
> The third:
>
> (defn my-fn
>   [pojo bar]
>   (let [bar-bar (.getSomething pojo)]
> (when-not (is-bar? bar)
>   (.setSomething pojo bar-bar))
> pojo)))
>
> let also (just like defn) includes an implicit do for the body.
>
> Hope this helps.
>
> Kind regards
> Meikel
>  
>

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

Re: Questions regarding do form

2012-09-27 Thread Russell Whitaker
On Thu, Sep 27, 2012 at 8:26 AM, arekanderu  wrote:
> Thank you Meikel for your so helpful replies.
>

Thanks also from a lurker, to whom these facts were a useful surprise:
I'd wondered
the same myself.

Cheers, R

>
> On Thursday, September 27, 2012 4:19:44 PM UTC+3, Meikel Brandmeyer
> (kotarak) wrote:
>>
>> Hi,
>>
>> Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:
>>
>>> I am new to clojure and I have two questions about do and the way it
>>> should be used.
>>>
>>> Question 1: Which of the following two functions is more idiomatic and
>>> why? Both functions produce the same result.
>>>
>>> 
>>> (defn my-fn [java-object]
>>>   (. java-object firstFunc)
>>>   (. java-object secondFunc)
>>>   (. java-object thirdFunc)
>>>   java-object)
>>> 
>>
>>
>> The first because defn includes an implicit do. So the second example is
>> actually (do (do ...)).
>>
>> In this case you could also use doto:
>>
>> (defn my-fn
>>   [pojo]
>>   (doto pojo
>> .firstFunc
>> .secondFunc
>> .thirdFunc))
>>
>>
>>>
>>> Question 2: Again, which one is more idiomatic and why? Both functions
>>> produce the same result.
>>>
>>> 
>>> (defn my-fn [java-object bar]
>>>   (let [bar-bar (. java-object getSomething)
>>> _   (if (not (is-bar? bar))
>>>   (. java-object (setSomething bar-bar)))]
>>> java-object))
>>> 
>>>
>>> 
>>> (defn my-fn [java-object bar]
>>>   (let [bar-bar (. java-object getSomething)]
>>> (do
>>>   (if (not (is-bar? bar))
>>> (. java-object (setSomething bar-bar)))
>>>  java-object)))
>>> 
>>
>>
>> The third:
>>
>> (defn my-fn
>>   [pojo bar]
>>   (let [bar-bar (.getSomething pojo)]
>> (when-not (is-bar? bar)
>>   (.setSomething pojo bar-bar))
>> pojo)))
>>
>> let also (just like defn) includes an implicit do for the body.
>>
>> Hope this helps.
>>
>> Kind regards
>> Meikel
>>

-- 
Russell Whitaker
http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/
http://www.linkedin.com/pub/russell-whitaker/0/b86/329

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


Re: Questions regarding do form

2012-09-27 Thread Grant Rettke
I'm reading _The Joy of Clojure_ right now, and they touch on it,
which is nice coming from Scheme/Racket.

On Thu, Sep 27, 2012 at 10:40 AM, Russell Whitaker
 wrote:
> On Thu, Sep 27, 2012 at 8:26 AM, arekanderu  wrote:
>> Thank you Meikel for your so helpful replies.
>>
>
> Thanks also from a lurker, to whom these facts were a useful surprise:
> I'd wondered
> the same myself.
>
> Cheers, R
>
>>
>> On Thursday, September 27, 2012 4:19:44 PM UTC+3, Meikel Brandmeyer
>> (kotarak) wrote:
>>>
>>> Hi,
>>>
>>> Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:
>>>
 I am new to clojure and I have two questions about do and the way it
 should be used.

 Question 1: Which of the following two functions is more idiomatic and
 why? Both functions produce the same result.

 
 (defn my-fn [java-object]
   (. java-object firstFunc)
   (. java-object secondFunc)
   (. java-object thirdFunc)
   java-object)
 
>>>
>>>
>>> The first because defn includes an implicit do. So the second example is
>>> actually (do (do ...)).
>>>
>>> In this case you could also use doto:
>>>
>>> (defn my-fn
>>>   [pojo]
>>>   (doto pojo
>>> .firstFunc
>>> .secondFunc
>>> .thirdFunc))
>>>
>>>

 Question 2: Again, which one is more idiomatic and why? Both functions
 produce the same result.

 
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)
 _   (if (not (is-bar? bar))
   (. java-object (setSomething bar-bar)))]
 java-object))
 

 
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)]
 (do
   (if (not (is-bar? bar))
 (. java-object (setSomething bar-bar)))
  java-object)))
 
>>>
>>>
>>> The third:
>>>
>>> (defn my-fn
>>>   [pojo bar]
>>>   (let [bar-bar (.getSomething pojo)]
>>> (when-not (is-bar? bar)
>>>   (.setSomething pojo bar-bar))
>>> pojo)))
>>>
>>> let also (just like defn) includes an implicit do for the body.
>>>
>>> Hope this helps.
>>>
>>> Kind regards
>>> Meikel
>>>
>
> --
> Russell Whitaker
> http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/
> http://www.linkedin.com/pub/russell-whitaker/0/b86/329
>
> --
> 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



-- 
((λ (x) (x x)) (λ (x) (x x)))
http://www.wisdomandwonder.com/
ACM, AMA, COG, IEEE

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


Re: Questions regarding do form

2012-09-27 Thread Wes Freeman
Thanks for mentioning doto--hadn't seen that before. Particularly, I think
some of my unit tests can be made significantly more readable with that.

Wes

On Thu, Sep 27, 2012 at 11:40 AM, Russell Whitaker <
russell.whita...@gmail.com> wrote:

> On Thu, Sep 27, 2012 at 8:26 AM, arekanderu  wrote:
> > Thank you Meikel for your so helpful replies.
> >
>
> Thanks also from a lurker, to whom these facts were a useful surprise:
> I'd wondered
> the same myself.
>
> Cheers, R
>
> >
> > On Thursday, September 27, 2012 4:19:44 PM UTC+3, Meikel Brandmeyer
> > (kotarak) wrote:
> >>
> >> Hi,
> >>
> >> Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:
> >>
> >>> I am new to clojure and I have two questions about do and the way it
> >>> should be used.
> >>>
> >>> Question 1: Which of the following two functions is more idiomatic and
> >>> why? Both functions produce the same result.
> >>>
> >>> 
> >>> (defn my-fn [java-object]
> >>>   (. java-object firstFunc)
> >>>   (. java-object secondFunc)
> >>>   (. java-object thirdFunc)
> >>>   java-object)
> >>> 
> >>
> >>
> >> The first because defn includes an implicit do. So the second example is
> >> actually (do (do ...)).
> >>
> >> In this case you could also use doto:
> >>
> >> (defn my-fn
> >>   [pojo]
> >>   (doto pojo
> >> .firstFunc
> >> .secondFunc
> >> .thirdFunc))
> >>
> >>
> >>>
> >>> Question 2: Again, which one is more idiomatic and why? Both functions
> >>> produce the same result.
> >>>
> >>> 
> >>> (defn my-fn [java-object bar]
> >>>   (let [bar-bar (. java-object getSomething)
> >>> _   (if (not (is-bar? bar))
> >>>   (. java-object (setSomething bar-bar)))]
> >>> java-object))
> >>> 
> >>>
> >>> 
> >>> (defn my-fn [java-object bar]
> >>>   (let [bar-bar (. java-object getSomething)]
> >>> (do
> >>>   (if (not (is-bar? bar))
> >>> (. java-object (setSomething bar-bar)))
> >>>  java-object)))
> >>> 
> >>
> >>
> >> The third:
> >>
> >> (defn my-fn
> >>   [pojo bar]
> >>   (let [bar-bar (.getSomething pojo)]
> >> (when-not (is-bar? bar)
> >>   (.setSomething pojo bar-bar))
> >> pojo)))
> >>
> >> let also (just like defn) includes an implicit do for the body.
> >>
> >> Hope this helps.
> >>
> >> Kind regards
> >> Meikel
> >>
>
> --
> Russell Whitaker
> http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/
> http://www.linkedin.com/pub/russell-whitaker/0/b86/329
>
> --
> 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 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

how do I evaluate this lazy sequence?

2012-09-27 Thread larry google groups
I would like 2 types of advice:

1.) an answer to this specific question

2.) advice on how one is suppose to debug mysteries likes this

I have a simple web app that serves some data (hopefully in JSON
format, but at the moment I will accept anything at all). The app uses
Ring and Moustache and outputs the data.

We start with a simple atom:

(def registry (atom {}))

We put some data in this atom. And then we output it. But I have had
great difficulty getting anything to appear on the screen. Assuming
the problem was with the fact the main sequence was lazy, I added in
doall everywhere it made sense. But I still can not get anything to
work:

(defn current-users [request]
  "The default action of this app. Add new users to the registry, and
delete the ones that are more than 15 seconds old"
  (let [this-users-params (:params request)
final-map-for-output {}]
  (add-to-logged-in-registry this-users-params)
  (remove-old-registrants)
  (response (apply str (into {}
 (doall
  (map (fn [each-user-map]
 (doall
  (let [inner-details (second each-
user-map)]
(assoc final-map-for-output
"username" (get inner-details "username" "nothing found for user"))
(assoc final-map-for-output
"updated" (get inner-details "updated" "nothing found for updated"))
final-map-for-output)))
   @registry)))

The various variations I have tried on this have either given me a
blank white page or:

{}

Nothing else.

I used to do simply:

  (response (apply str (doall @registry)

This worked fine. But it did not output valid JSON, so I wanted to
change the format. But I have not been able to get anything to appear
on screen.

Suggestions?

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


Re: how do I evaluate this lazy sequence?

2012-09-27 Thread Tassilo Horn
larry google groups  writes:

> We put some data in this atom. And then we output it. But I have had
> great difficulty getting anything to appear on the screen. Assuming
> the problem was with the fact the main sequence was lazy, I added in
> doall everywhere it made sense. But I still can not get anything to
> work:

Your problem's here and has nothing to do with lazyness:

>   (let [inner-details (second each-user-map)]
>  (assoc final-map-for-output "username" (get inner-details 
> "username" "nothing found for user"))
>  (assoc final-map-for-output "updated" (get inner-details 
> "updated" "nothing found for updated"))
>  final-map-for-output)))

assoc (and all clojure collection functions) doesn't modify the given
map but it returns a new version of the given map with the new
association.  You simply don't use it.

Maybe you want something like this in case you want to output pairs of
"username"/inner-details, and "updated"/inner-details pairs.

--8<---cut here---start->8---
(defn current-users [request]
  "The default action of this app. Add new users to the registry, and
delete the ones that are more than 15 seconds old"
  (let [this-users-params (:params request)]
(add-to-logged-in-registry this-users-params)
(remove-old-registrants)
(response (apply str
 (mapcat
  (fn [each-user-map]
(let [inner-details (second each-user-map)]
  [["username" (get inner-details "username"
"nothing found for user")]
   ["updated" (get inner-details "updated"
   "nothing found for updated")]]))
  @registry)
--8<---cut here---end--->8---

Bye,
Tassilo

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


Re: how do I evaluate this lazy sequence?

2012-09-27 Thread gaz jones
Couple of initial things, Clojure has immutable data structures so
when you call for example 'assoc' it will return you a new map with
the new values assoc'd. It will not mutate the original, so:

(let [foo {}]
  (assoc foo :a 1)
  (assoc foo :b 2)
  foo)

Will return {}. You need to do something like:

(-> {}
 (assoc :a 1)
 (assoc :b 2))

=> {:a 1 :b 2}

FYI, assoc takes multiple kvps:

(assoc {} :a 1 :b 2)

Also, to return valid JSON, you cannot simply call 'str' on the map.
You need to use a library like https://github.com/dakrone/cheshire or
https://github.com/clojure/data.json and encode the map as JSON.

Perhaps you could illustrate the data structure you are holding inside
of @registry, and the structure of the JSON you would like to emit.
Laziness is not an issue here.


On Thu, Sep 27, 2012 at 12:02 PM, larry google groups
 wrote:
> I would like 2 types of advice:
>
> 1.) an answer to this specific question
>
> 2.) advice on how one is suppose to debug mysteries likes this
>
> I have a simple web app that serves some data (hopefully in JSON
> format, but at the moment I will accept anything at all). The app uses
> Ring and Moustache and outputs the data.
>
> We start with a simple atom:
>
> (def registry (atom {}))
>
> We put some data in this atom. And then we output it. But I have had
> great difficulty getting anything to appear on the screen. Assuming
> the problem was with the fact the main sequence was lazy, I added in
> doall everywhere it made sense. But I still can not get anything to
> work:
>
> (defn current-users [request]
>   "The default action of this app. Add new users to the registry, and
> delete the ones that are more than 15 seconds old"
>   (let [this-users-params (:params request)
> final-map-for-output {}]
>   (add-to-logged-in-registry this-users-params)
>   (remove-old-registrants)
>   (response (apply str (into {}
>  (doall
>   (map (fn [each-user-map]
>  (doall
>   (let [inner-details (second each-
> user-map)]
> (assoc final-map-for-output
> "username" (get inner-details "username" "nothing found for user"))
> (assoc final-map-for-output
> "updated" (get inner-details "updated" "nothing found for updated"))
> final-map-for-output)))
>@registry)))
>
> The various variations I have tried on this have either given me a
> blank white page or:
>
> {}
>
> Nothing else.
>
> I used to do simply:
>
>   (response (apply str (doall @registry)
>
> This worked fine. But it did not output valid JSON, so I wanted to
> change the format. But I have not been able to get anything to appear
> on screen.
>
> Suggestions?
>
> --
> 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 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


Re: Light Table Playground got a lot more useful.

2012-09-27 Thread Chris Granger
Cmd/Ctrl means either the Cmd key (which is on macs) or the Ctrl key on
windows/linux. So if it says Cmd/Ctrl + d that would mean just ctrl + d.

Cheers,
Chris.

On Wed, Sep 26, 2012 at 5:01 PM, humblepie  wrote:

> For the life of me I can figure out the key binding for the Cmd key. Can
> someone help?
>
>
> On Monday, July 9, 2012 6:27:26 PM UTC-7, Chris Granger wrote:
>>
>> Hey folks,
>>
>> In case you missed it via other channels, the Light Table Playground
>> can now hook into your own projects!
>>
>> http://www.chris-granger.com/**2012/07/09/light-table-**
>> playgrounds-level-up/
>>
>> Take her for a spin :D
>>
>> Cheers,
>> Chris.
>
>  --
> 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 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

Re: how do I evaluate this lazy sequence?

2012-09-27 Thread Jim - FooBar();
the 2 previous responses answered your question perfectly ...I'm just  a 
bit amazed that you would go away and write clojure code to consume JSON 
and all that, without realising that data-structures in Clojure are 
immutable! I think we can all agree they are *the* cornerstone of 
Clojure. It is a bit alien at first but it does pay off in the long 
run... If you absolutely need to stick with your code style (mutability 
not-recommended in general) use a java HashMap instead...


Jim

ps: i recently used a cheshire without any problems :-)

On 27/09/12 18:53, gaz jones wrote:

Couple of initial things, Clojure has immutable data structures so
when you call for example 'assoc' it will return you a new map with
the new values assoc'd. It will not mutate the original, so:

(let [foo {}]
   (assoc foo :a 1)
   (assoc foo :b 2)
   foo)

Will return {}. You need to do something like:

(-> {}
  (assoc :a 1)
  (assoc :b 2))

=> {:a 1 :b 2}

FYI, assoc takes multiple kvps:

(assoc {} :a 1 :b 2)

Also, to return valid JSON, you cannot simply call 'str' on the map.
You need to use a library like https://github.com/dakrone/cheshire or
https://github.com/clojure/data.json and encode the map as JSON.

Perhaps you could illustrate the data structure you are holding inside
of @registry, and the structure of the JSON you would like to emit.
Laziness is not an issue here.


On Thu, Sep 27, 2012 at 12:02 PM, larry google groups
 wrote:

I would like 2 types of advice:

1.) an answer to this specific question

2.) advice on how one is suppose to debug mysteries likes this

I have a simple web app that serves some data (hopefully in JSON
format, but at the moment I will accept anything at all). The app uses
Ring and Moustache and outputs the data.

We start with a simple atom:

(def registry (atom {}))

We put some data in this atom. And then we output it. But I have had
great difficulty getting anything to appear on the screen. Assuming
the problem was with the fact the main sequence was lazy, I added in
doall everywhere it made sense. But I still can not get anything to
work:

(defn current-users [request]
   "The default action of this app. Add new users to the registry, and
delete the ones that are more than 15 seconds old"
   (let [this-users-params (:params request)
 final-map-for-output {}]
   (add-to-logged-in-registry this-users-params)
   (remove-old-registrants)
   (response (apply str (into {}
  (doall
   (map (fn [each-user-map]
  (doall
   (let [inner-details (second each-
user-map)]
 (assoc final-map-for-output
"username" (get inner-details "username" "nothing found for user"))
 (assoc final-map-for-output
"updated" (get inner-details "updated" "nothing found for updated"))
 final-map-for-output)))
@registry)))

The various variations I have tried on this have either given me a
blank white page or:

{}

Nothing else.

I used to do simply:

   (response (apply str (doall @registry)

This worked fine. But it did not output valid JSON, so I wanted to
change the format. But I have not been able to get anything to appear
on screen.

Suggestions?

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

CLR Reflection Laziness

2012-09-27 Thread James Ashley
Greetings, all.

Clojure newb here. Life's more difficult because I have to deal with CLR 
3.5.

I'm going through the resources I can find. And I'm totally typing this in 
off the
top of my head, even though I know it's evil. I apologize for that. I think 
the gist
gets across, though.

One's a blog that shows code that amounts to:

(Assembly/LoadPartialNameSpace ... "a")
(Assembly/LoadPartialNameSpace ... "b") 
(Assembly/LoadPartialNameSpace ... "c") 

(ns whatever
  ;; Actually *use* those assemblies
)

My first reaction: "This is lame. Why not do something like..."

(defn LoadNames [names]
  map (fn[name]
Assembly/LoadPartialName name))
(ns )

Typing this in at a REPL worked fine (well, a reasonable Null exception). 
Running it from a script resulted in an unhandled NullArgumentException (or 
something along those lines...I *know* how bad I hate error reports this 
vague, but this is why I'm just asking whether it should *be* a bug report 
in the first place). Which led to Windows doing its "This program has quit 
unexpectedly" thing, followed by a trip into the debugger.

My *real* problem was laziness...I meant (doseq ...) instead of (map...).

Does this qualify as a bug?

It's a stupid mistake on my part. I expect to be dumped to the REPL with an 
error about the exception.

This probably qualifies as stupid edge-case undefined behavior. I failed to 
load an assembly that the ns macro referred to later.

But I cringe away from that...I don't think that I should *ever* be able to 
type in anything in clojure that leads to an unhandled exception. I can see 
pros and cons both ways, and I don't know what (if any) the community 
consensus might be.

The fact that running it from the REPL results in different behavior than 
running the script is my hang-up. Normally I'd just go try to figure out 
how standard clojure (JVM) handles a similar situation, but this doesn't 
seem to apply.

So, I guess the question is: Bug, or simple PEBKAC?

Thanks all,
James



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

Re: Data Structure server (Redis in Clojure)

2012-09-27 Thread Artem Yankov
By the way, i figured performance issue (there was a prn call for each 
command which significantly slowed everything down, heh).
Now, numbers are close to Redis, except for lrange for big lists and I 
havent' tested zsets yet. Need to gain more experience in jvm tweaking
and data structure optimization i guess..

On Wednesday, September 19, 2012 10:01:09 AM UTC-7, Artem Yankov wrote:
>
> Those are a bit different. Naming of data structures in Redis can be a bit 
> confusing. What's called
> a sorted set actually is more like a sorted map - keys mapped to scores 
> and set is sorted by scores.
>
> On Tuesday, September 18, 2012 5:51:25 AM UTC-7, Moritz Ulrich wrote:
>>
>>
>> Hi! 
>>
>> I don't have the time to look at your code right now, but I have one 
>> suggestion: 
>>
>> Artem Yankov writes: 
>>
>> > 2. What would be a best way to implement sorted sets (like in Redis)? I 
>> > used sorted maps and sorting them by values which I highly doubt is a 
>> > log(n) operation.. 
>>
>> `clojure.core/sorted-set' and `clojure.core/sorted-set-by' 
>>
>> http://clojuredocs.org/clojure_core/clojure.core/sorted-set 
>>
>> -- 
>> Moritz Ulrich 
>>
>

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