clojure.core.unify and exceptions

2012-06-06 Thread Kevin Livingston
I was surprised to find that clojure.core.unify returns an exception when something does not unify rather than something like nil (false) when they don't. If you always expect something to unify, I guess sure, but a very standard use of a unifier is to test if two things unify or not, where it's a

Re: Friend: an extensible authentication and authorization library for Clojure Ring webapps and services

2012-06-06 Thread Pelle Braendgaard
To see how to use it in a noir context I created this demo app: https://github.com/pelle/oauthentic-demo/blob/master/src/oauthentic_demo/views/welcome.clj#L32 It authenticates to GitHub with OAuth2 Try it out here: http://oauthentic.herokuapp.com/ P On Wed, Jun 6, 2012 at 4:47 PM, Pelle Braend

Re: Friend: an extensible authentication and authorization library for Clojure Ring webapps and services

2012-06-06 Thread Pelle Braendgaard
I've written a simple OAuth2 library oauthentic https://github.com/pelle/oauthentic which should make it easy to connect to at least Facebook as it only supports oauth2. I started investigating connecting it with friend and it looks pretty simple, but haven't currently got any time to do so. P O

Re: hyphenate - imperative for

2012-06-06 Thread Andy Fingerhut
Dave: I don't know if it will help you do it more succinctly, and I don't know whether with-local-vars is implemented in ClojureScript, but at least in Clojure with-local-vars is a way to have local mutable variables in a single-threaded piece of code, and know that the mutability stays local t

London Clojurians Website Hackday

2012-06-06 Thread Dale Thatcher
All, The London Clojurians are hosting a hackday to work on their community website (http://londonclojurians.org) on Saturday 16th June 10:00-16:00 BST. All welcome, details here: http://ldncljweb-june2012.eventbrite.com/ Hope to see you there! - Dale -- You received this message because

Re: CRUD application backed only by immutable facts

2012-06-06 Thread 江海龙
I've been concerning this problem for a few months. The "transaction logs" is actually the history events of an entity. With an initial state is offer, the current state of an entity can be calculated with the help of history events. So if you want to know a property of an entity currently, these

Now you can write Clojure online

2012-06-06 Thread Anders Persson
The http://www.compileonline.com have Clojure as one language, test it. /Anders -- 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 pa

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Tassilo Horn
"Z.A" writes: > Meikel : To get the sequence printing logic i tried following code. Makes > no sense to me. > >(def lazy2 (take 3 (iterate #(do > (cond > (= 0 %) (print "+") > (= 1 %) (p

Re: hyphenate - imperative for

2012-06-06 Thread Dave Sann
Good point and fair enough - I wasn't aware of this. On Wednesday, 6 June 2012 23:41:32 UTC+10, Tassilo Horn wrote: > > > > On transients: > > At the moment, I disagree - I think that there are some situations > > where *strictly contained* mutability can make a solution simpler as > > well as

Re: hyphenate - imperative for

2012-06-06 Thread Tassilo Horn
Dave Sann writes: > On transients: > At the moment, I disagree - I think that there are some situations > where *strictly contained* mutability can make a solution simpler as > well as possibly more efficient. I offer no proof :) You might be right or not, but Stephen is completely right that yo

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Z.A
Thanks everybody. Meikel : To get the sequence printing logic i tried following code. Makes no sense to me. (def lazy2 (take 3 (iterate #(do (cond (= 0 %) (print "+") (= 1 %) (print "*")

Re: hyphenate - imperative for

2012-06-06 Thread Dave Sann
Hi Stephen, thanks for the answer. Let me be more clear. I am porting the functionality, not the form of the code. I want to use pure clojure - because I'd like it available to clojure and clojurescript. Generally: I can write code that will do what this does - but I can't (so far) do it succ

Re: hyphenate - imperative for

2012-06-06 Thread Stephen Compall
On Jun 6, 2012 7:23 AM, "Dave Sann" wrote: > The question is: what is the best way to write such a function in clojure. You will never get the clarity you're looking for with a direct port; you must find and use appropriate Clojurian abstractions. I suggest starting by thinking about ways to elim

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Pierre-Henry Perret
A form like: (def lazy2 (map #(str "+" %) (range))) would work. Le mercredi 6 juin 2012 11:24:06 UTC+2, Z.A a écrit : > > Hi > > user=> (def lazy1(take3 (iterate#(do (print "+") > (inc %))0))) > #'user/lazy1 > user=> lazy1 > (+0+1 2) > > Why am I not gettin

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 6. Juni 2012 12:13:56 UTC+2 schrieb Jim foo.bar: Your f is NOT free of side-effects...Nonetheless, I would expect (0 +1 > +2) instead of (+0 +1 2)! > Can anyone shine some light on this? > > When printing the sequence the tail is realized before the current item is printed

hyphenate - imperative for

2012-06-06 Thread Dave Sann
I am porting this code to pure clojure http://nedbatchelder.com/code/modules/hyphenate.py It's relatively simple - but it raises an interesting problem (for me) which is this: The function hyphenate - can be considered to be a pure function - if you make tree and exceptions arguments The for l

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Pierre-Henry Perret
This is due to the fact that the evaluation of a do form returns the last expr... Le mercredi 6 juin 2012 12:23:07 UTC+2, Jim foo.bar a écrit : > > It's obvious that you're looking for: > > (def lazy1 (interleave (repeat '+) (range 3))) > > > but I still haven't figured out why you get: (+0 +

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Jim - FooBar();
It's obvious that you're looking for: (def lazy1 (interleave (repeat '+) (range 3))) but I still haven't figured out why you get: (+0 +1 2) when using iterate! Jim On 06/06/12 11:13, Jim - FooBar(); wrote: From the docs: clojure.core/iterate ([f x]) Returns a lazy sequence of x, (f x

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Jim - FooBar();
From the docs: clojure.core/iterate ([f x]) Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects Your f is NOT free of side-effects...Nonetheless, I would expect (0 +1 +2) instead of (+0 +1 2)! Can anyone shine some light on this? Jim On 06/06/12 10:24, Z

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Meikel Brandmeyer (kotarak)
Hi, because the first element is taken verbatim and the function is not applied to it. In this case it is the zero. (iterate f x) => (x (f x) (f (f x)) ...) So the pluses you see are for the 1 and the 2. Kind regards Meikel -- You received this message because you are subscribed to the Googl

Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Z.A
Hi user=> (def lazy1(take3 (iterate#(do (print "+") (inc %))0))) #'user/lazy1 user=> lazy1 (+0+1 2) Why am I not getting (+0+1+2) ? Thanks Zubair PS: I am reading chapter 6 of 'The Joy of Clojure' and trying to understand "rest versus next" , pp 1

Re: CRUD application backed only by immutable facts

2012-06-06 Thread Angel Java Lopez
Yes, I thought the same... Now, encouraged by Dave message ;-) some links: http://martinfowler.com/eaaDev/EventSourcing.html Dave mentioned CQRS, some post about Events, Event Sourcing AND CQRS: http://thinkbeforecoding.com/tag/CQRS CQRS (Command Query Responsibility Separation) is a big topic, po

Re: CRUD application backed only by immutable facts

2012-06-06 Thread Dave Sann
This sounds a lot like Event Sourcing to me. (often coupled with CQRS). Which, I think, is similar to what datomic is doing, where: - datom => event - transactor => event store - peer => query model There are a number of presentations, blogs available on this if you haven't seen