Re: CRUD application backed only by immutable facts

2012-06-05 Thread nicolas.o...@gmail.com
It is not totally clear in your post how you want to keep the data?
Is it in memory (with a transactional log somewhere)?
If it is the case, you can do better than reducing the whole data set
when executing a query:
you can keep a cache of query results, or indexed data and maintain
it, while still being
purely functional. (For example by attaching those results as meta
data to the data structure, and
defining your own assoc-like functions that maintain a consistency of
the meta-dataed query results)

On Tue, Jun 5, 2012 at 1:59 AM, Kevin Lynagh ke...@keminglabs.com wrote:
 Has anyone seen or implemented a CRUD application in Clojure using a
 database of immutable facts?

 For instance, a traditional database table supporting a todo-list
 application has columns

    user_id, task_id, task_description, is_done

 A new row is created when a user adds a task.
 Then that row is updated so is_done = TRUE when the user checks the
 task off.

 With immutable facts this would instead be a collection of statements:

 User U added task T with description D at time T1
 User U completed task T at time T2

 To get a list of unfinished tasks for a user, you'd need to grab all
 the tasks from this transaction log, put them into a data structure,
 and then remove ones when you learn that they've been completed.
 Whatever is left over is the todo list.

 Nathan Marz talked about this in terms of big data:

    http://nathanmarz.com/blog/how-to-beat-the-cap-theorem.html

 and Datomic's big bet is that your life as a developer gets much
 easier when you just deal with (entity, attribute, value) + time.

 I buy it in theory, but I have no idea what to expect in terms of
 performance (e.g., how long would it take to find the current todo
 list of someone who has added and completed/removed a few thousand
 items?).

 Has anyone implemented this idea on Clojure datastructures using,
 say,  (timestamp, keyseq, value) and reducing a ton of calls to assoc-
 in?
 Aside from speed, what are some other tradeoffs of an immutable
 approach?

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



-- 
Sent from an IBM Model M, 15 August 1989.

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


Creating a hashmap

2012-06-05 Thread Christian Guimaraes
Hello all,

I'm studying a little bit of Clojure and facing a doubt here.

I hava a list (a b c) and want to create a hashmap using the elements from
this list.

The keys will be a sequential number, and the values will be the values
from the previous list.

1. list:
  (a b c)

2. desired hashmap:
  (hash-map 1 a 2 b 3 c)

How can I achieve this in a idiomatic functional way?

Cheers. And thank you for your attention.

-- christian

-- 
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: Creating a hashmap

2012-06-05 Thread Jay Fields
(zipmap (range 1 4) [a b c])

On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes cguimaraes...@gmail.com
 wrote:

 Hello all,

 I'm studying a little bit of Clojure and facing a doubt here.

 I hava a list (a b c) and want to create a hashmap using the elements from
 this list.

 The keys will be a sequential number, and the values will be the values
 from the previous list.

 1. list:
   (a b c)

 2. desired hashmap:
   (hash-map 1 a 2 b 3 c)

 How can I achieve this in a idiomatic functional way?

 Cheers. And thank you for your attention.

 -- christian

 --
 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: Creating a hashmap

2012-06-05 Thread Jay Fields
Also, if you're looking to learn this kind of stuff, 4clojure.com is an
excellent resource.

On Tue, Jun 5, 2012 at 8:02 AM, Jay Fields j...@jayfields.com wrote:

 (zipmap (range 1 4) [a b c])


 On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes 
 cguimaraes...@gmail.com wrote:

 Hello all,

 I'm studying a little bit of Clojure and facing a doubt here.

 I hava a list (a b c) and want to create a hashmap using the elements
 from this list.

 The keys will be a sequential number, and the values will be the values
 from the previous list.

 1. list:
   (a b c)

 2. desired hashmap:
   (hash-map 1 a 2 b 3 c)

 How can I achieve this in a idiomatic functional way?

 Cheers. And thank you for your attention.

 -- christian

 --
 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: Creating a hashmap

2012-06-05 Thread Ambrose Bonnaire-Sergeant
Or: (zipmap (map inc (range)) '(a b c))

Thanks,
Ambrose

On Tue, Jun 5, 2012 at 8:02 PM, Jay Fields j...@jayfields.com wrote:

 (zipmap (range 1 4) [a b c])


 On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes 
 cguimaraes...@gmail.com wrote:

 Hello all,

 I'm studying a little bit of Clojure and facing a doubt here.

 I hava a list (a b c) and want to create a hashmap using the elements
 from this list.

 The keys will be a sequential number, and the values will be the values
 from the previous list.

 1. list:
   (a b c)

 2. desired hashmap:
   (hash-map 1 a 2 b 3 c)

 How can I achieve this in a idiomatic functional way?

 Cheers. And thank you for your attention.

 -- christian

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


-- 
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: Friend: an extensible authentication and authorization library for Clojure Ring webapps and services

2012-06-05 Thread DAemon
Hi Chas,

Was wondering whether there's been any work on extending Friend to OAuth
stuff yet - I'm looking at implementing something that requires
authentication with Twitter or Facebook, and haven't quite got my head
around all the steps required to implement it myself...

Thanks!

- David

On Thu, Apr 12, 2012 at 12:59 AM, Chas Emerick c...@cemerick.com wrote:

  For your consideration, a new library http://wp.me/p10OJi-d6:

  I’m hoping this can eventually be
 a warden/spring-security/everyauth /omniauth for Clojure; that is, a common
 abstraction for authentication and authorization mechanisms.  Clojure has
 been around long enough that adding pedestrian things like form and HTTP
 Basic and $AUTH_METHOD_HERE to a Ring application should be easy.  Right
 now, it’s not: either you’re pasting together a bunch of different
 libraries that don’t necessarily compose well together, or you get drawn
 into shaving the authentication and authorization yaks for the fifth time
 in your life so you can sleep well at night.

 Hopefully Friend will make this a solved problem, or at least push things
 in that direction.


 Read more here: http://wp.me/p10OJi-d6

 Cheers,

 - Chas

 --
 http://cemerick.com
 [Clojure Programming from O'Reilly](http://www.clojurebook.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

-- 
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: Creating a hashmap

2012-06-05 Thread Christian Guimaraes
Awesome...

I'm studying lists manipulation. Solidifying this concept. The basic in
Clojure, in my point of view.

Thanks again.

On Tue, Jun 5, 2012 at 1:03 PM, Ambrose Bonnaire-Sergeant 
abonnaireserge...@gmail.com wrote:

 Or: (zipmap (map inc (range)) '(a b c))

 Thanks,
 Ambrose


 On Tue, Jun 5, 2012 at 8:02 PM, Jay Fields j...@jayfields.com wrote:

 (zipmap (range 1 4) [a b c])


 On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes 
 cguimaraes...@gmail.com wrote:

 Hello all,

 I'm studying a little bit of Clojure and facing a doubt here.

 I hava a list (a b c) and want to create a hashmap using the elements
 from this list.

 The keys will be a sequential number, and the values will be the values
 from the previous list.

 1. list:
   (a b c)

 2. desired hashmap:
   (hash-map 1 a 2 b 3 c)

 How can I achieve this in a idiomatic functional way?

 Cheers. And thank you for your attention.

 -- christian

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


  --
 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: Creating a hashmap

2012-06-05 Thread Baishampayan Ghose
Or: (zipmap (drop 1 (range)) '(a b c))

:-)

Regards,
BG

On Tue, Jun 5, 2012 at 5:33 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
 Or: (zipmap (map inc (range)) '(a b c))

 Thanks,
 Ambrose


 On Tue, Jun 5, 2012 at 8:02 PM, Jay Fields j...@jayfields.com wrote:

 (zipmap (range 1 4) [a b c])


 On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes
 cguimaraes...@gmail.com wrote:

 Hello all,

 I'm studying a little bit of Clojure and facing a doubt here.

 I hava a list (a b c) and want to create a hashmap using the elements
 from this list.

 The keys will be a sequential number, and the values will be the values
 from the previous list.

 1. list:
   (a b c)

 2. desired hashmap:
   (hash-map 1 a 2 b 3 c)

 How can I achieve this in a idiomatic functional way?

 Cheers. And thank you for your attention.

 -- christian

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


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



-- 
Baishampayan Ghose
b.ghose at gmail.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


Re: Creating a hashmap

2012-06-05 Thread Jay Fields
If I needed the range to be infinite I'd probably use: (zipmap (iterate inc
1) '(a b c))

On Tue, Jun 5, 2012 at 8:13 AM, Baishampayan Ghose b.gh...@gmail.comwrote:

 Or: (zipmap (drop 1 (range)) '(a b c))

 :-)

 Regards,
 BG

 On Tue, Jun 5, 2012 at 5:33 PM, Ambrose Bonnaire-Sergeant
 abonnaireserge...@gmail.com wrote:
  Or: (zipmap (map inc (range)) '(a b c))
 
  Thanks,
  Ambrose
 
 
  On Tue, Jun 5, 2012 at 8:02 PM, Jay Fields j...@jayfields.com wrote:
 
  (zipmap (range 1 4) [a b c])
 
 
  On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes
  cguimaraes...@gmail.com wrote:
 
  Hello all,
 
  I'm studying a little bit of Clojure and facing a doubt here.
 
  I hava a list (a b c) and want to create a hashmap using the elements
  from this list.
 
  The keys will be a sequential number, and the values will be the values
  from the previous list.
 
  1. list:
(a b c)
 
  2. desired hashmap:
(hash-map 1 a 2 b 3 c)
 
  How can I achieve this in a idiomatic functional way?
 
  Cheers. And thank you for your attention.
 
  -- christian
 
  --
  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
 
 
  --
  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



 --
 Baishampayan Ghose
 b.ghose at gmail.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


-- 
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: user.clj not working with lein 2.0

2012-06-05 Thread Jim - FooBar();
Does the :injections key replace the init.clj found in /.lein/? If I 
understood correctly, I had roughly the same problem...my code in 
init.clj (some debugging functions I always need available) is no more 
being loaded with lein2...should I use the :injections key instead?


Thanks in advance...

Jim

On 05/06/12 04:12, Warren Lynn wrote:

:injections works! slime works too (with slime-describe-symbol for
doc). Thank you!

On Jun 4, 11:05 pm, Phil Hagelbergp...@hagelb.org  wrote:

On Mon, Jun 4, 2012 at 5:55 PM, Warren Lynnwrn.l...@gmail.com  wrote:

(use 'clojure.repl)
(use 'clojure.java.javadoc)
But now in the REPL I don't have clojure.repl namespace available
anymore. Can anyone tell me why user.clj does not take effect anymore?
Thank you.

Everything in clojure.repl has a nicer equivalent using slime, plus
you don't have to re-use it every time you switch namespaces.

If you need something loaded at boot you can use the :injections key
in the user profile to have a vector of forms evaluated every time
your project is started, but using it for clojure.repl is unnecessary
if you use slime.

-Phil


--
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: Creating a hashmap

2012-06-05 Thread Meikel Brandmeyer (kotarak)
And a completely different approach:

(into {} (map-indexed #(vector (inc %1) %2) [a b c]))

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: user.clj not working with lein 2.0

2012-06-05 Thread Phil Hagelberg
On Tue, Jun 5, 2012 at 5:20 AM, Jim - FooBar(); jimpil1...@gmail.com wrote:
 Does the :injections key replace the init.clj found in /.lein/? If I
 understood correctly, I had roughly the same problem...my code in init.clj
 (some debugging functions I always need available) is no more being loaded
 with lein2...should I use the :injections key instead?

No, they serve different purposes. init.clj runs inside the Leiningen
process itself. It's not checked explicitly for settings anymore, but
it's currently still loaded. This may go away before the final release
though since all the purposes it used to serve have been replaced.

-Phil

-- 
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: user.clj not working with lein 2.0

2012-06-05 Thread Jim - FooBar();

On 05/06/12 17:10, Phil Hagelberg wrote:

On Tue, Jun 5, 2012 at 5:20 AM, Jim - FooBar();jimpil1...@gmail.com  wrote:

Does the :injections key replace the init.clj found in /.lein/? If I
understood correctly, I had roughly the same problem...my code in init.clj
(some debugging functions I always need available) is no more being loaded
with lein2...should I use the :injections key instead?

No, they serve different purposes. init.clj runs inside the Leiningen
process itself. It's not checked explicitly for settings anymore, but
it's currently still loaded. This may go away before the final release
though since all the purposes it used to serve have been replaced.

-Phil



Ok I see...
then why can I not use my debug-repl, which is located in init.clj ? It 
only works when I'm in the 'user' namespace...I think this worked 
perfectly ok in lein1...at any given time I could do (debug-repl) and 
I would get the appropriate repl. Now I have to move code around between 
namespaces or have the debug-repl in every single project of mine!


any suggestions?

Jim

--
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: user.clj not working with lein 2.0

2012-06-05 Thread Jim - FooBar();

On 05/06/12 18:00, Jim - FooBar(); wrote:

On 05/06/12 17:10, Phil Hagelberg wrote:
On Tue, Jun 5, 2012 at 5:20 AM, Jim - 
FooBar();jimpil1...@gmail.com  wrote:

Does the :injections key replace the init.clj found in /.lein/? If I
understood correctly, I had roughly the same problem...my code in 
init.clj
(some debugging functions I always need available) is no more being 
loaded

with lein2...should I use the :injections key instead?

No, they serve different purposes. init.clj runs inside the Leiningen
process itself. It's not checked explicitly for settings anymore, but
it's currently still loaded. This may go away before the final release
though since all the purposes it used to serve have been replaced.

-Phil



Ok I see...
then why can I not use my debug-repl, which is located in init.clj ? 
It only works when I'm in the 'user' namespace...I think this worked 
perfectly ok in lein1...at any given time I could do (debug-repl) 
and I would get the appropriate repl. Now I have to move code around 
between namespaces or have the debug-repl in every single project of 
mine!


any suggestions?

Jim


Sorry, rereading your answer made me think my question should have been:

what has init.clj been replaced with? How can I always have my debug-repl?

Jim

--
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: user.clj not working with lein 2.0

2012-06-05 Thread Phil Hagelberg
On Tue, Jun 5, 2012 at 10:00 AM, Jim - FooBar(); jimpil1...@gmail.com wrote:
 Ok I see...
 then why can I not use my debug-repl, which is located in init.clj ? It only
 works when I'm in the 'user' namespace...I think this worked perfectly ok in
 lein1...at any given time I could do (debug-repl) and I would get the
 appropriate repl. Now I have to move code around between namespaces or have
 the debug-repl in every single project of mine!

I don't think this is a Leiningen issue. Clojure provides no way to
load something and have it referred in all namespaces. Even if it did,
it never would have worked with init.clj even in Leiningen 1.x since
that was loaded in a different process from your own code. Putting it
in user.clj would solve the second problem but not the first.

-Phil

-- 
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: Creating a hashmap

2012-06-05 Thread Tim Visher
On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes
cguimaraes...@gmail.com wrote:
 I hava a list (a b c) and want to create a hashmap using the elements from
 this list.

 The keys will be a sequential number, and the values will be the values from
 the previous list.

 1. list:
   (a b c)

 2. desired hashmap:
   (hash-map 1 a 2 b 3 c)

 How can I achieve this in a idiomatic functional way?

And now for something completely different:

 ([1 2 3] 0)
1
 ([1 2 3] 1)
2

I refer, of course, to the strange property of vectors in that they
are also functions of their index. So if you it's cool for you to have
the list be a vector and the access to be vector first then 'key',
then you need to write no code whatsoever.

--

Timmy V.

http://twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail.

-- 
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: Creating a hashmap

2012-06-05 Thread Christian Guimaraes
Thanks for the tip, Timmy. This is a very interesting Vector feature.

-- christian

On Tue, Jun 5, 2012 at 7:13 PM, Tim Visher tim.vis...@gmail.com wrote:

 On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes
 cguimaraes...@gmail.com wrote:
  I hava a list (a b c) and want to create a hashmap using the elements
 from
  this list.
 
  The keys will be a sequential number, and the values will be the values
 from
  the previous list.
 
  1. list:
(a b c)
 
  2. desired hashmap:
(hash-map 1 a 2 b 3 c)
 
  How can I achieve this in a idiomatic functional way?

 And now for something completely different:

 ([1 2 3] 0)
1
 ([1 2 3] 1)
2

 I refer, of course, to the strange property of vectors in that they
 are also functions of their index. So if you it's cool for you to have
 the list be a vector and the access to be vector first then 'key',
 then you need to write no code whatsoever.

 --

 Timmy V.

 http://twonegatives.com/
 http://five.sentenc.es/ -- Spend less time on mail.

 --
 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: user.clj not working with lein 2.0

2012-06-05 Thread Jim - FooBar();

On 05/06/12 18:17, Phil Hagelberg wrote:

On Tue, Jun 5, 2012 at 10:00 AM, Jim - FooBar();jimpil1...@gmail.com  wrote:

Ok I see...
then why can I not use my debug-repl, which is located in init.clj ? It only
works when I'm in the 'user' namespace...I think this worked perfectly ok in
lein1...at any given time I could do (debug-repl) and I would get the
appropriate repl. Now I have to move code around between namespaces or have
the debug-repl in every single project of mine!

I don't think this is a Leiningen issue. Clojure provides no way to
load something and have it referred in all namespaces. Even if it did,
it never would have worked with init.clj even in Leiningen 1.x since
that was loaded in a different process from your own code. Putting it
in user.clj would solve the second problem but not the first.

-Phil



Cool thanks a lot for the prompt reply...

Jim

--
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: CRUD application backed only by immutable facts

2012-06-05 Thread Kevin Lynagh
Jonas,

Definitely inspired by the ideas in Datomic.
My question was partially: how can I implement the core immutability
semantics of Datomic in plain Clojure?.
(Say, hypothetically, that I need a Clojure datastore with flexible
schema and immutability semantics but cannot actually use Datomic for
business reasons.)

I gave it a shot this morning---writing code to serialize

{:a 1 :b 2}

into

[#Assertion{:id 1, :attribute :a, :value 1, :time 0},
 #Assertion{:id 1, :attribute :b, :value 2, :time 0}]

and back again (which gets a bit more complex with references/
collections, but not much).

Nicolas,

Data can be kept anywhere that tuples can be kept = )
Caching intermediate values diffs are collapsed should definitely
bring a speedup.
The immutability semantics mean you really can go all out crazy with
the caching too.



On Jun 5, 1:44 am, nicolas.o...@gmail.com nicolas.o...@gmail.com
wrote:
 It is not totally clear in your post how you want to keep the data?
 Is it in memory (with a transactional log somewhere)?
 If it is the case, you can do better than reducing the whole data set
 when executing a query:
 you can keep a cache of query results, or indexed data and maintain
 it, while still being
 purely functional. (For example by attaching those results as meta
 data to the data structure, and
 defining your own assoc-like functions that maintain a consistency of
 the meta-dataed query results)









 On Tue, Jun 5, 2012 at 1:59 AM, Kevin Lynagh ke...@keminglabs.com wrote:
  Has anyone seen or implemented a CRUD application in Clojure using a
  database of immutable facts?

  For instance, a traditional database table supporting a todo-list
  application has columns

     user_id, task_id, task_description, is_done

  A new row is created when a user adds a task.
  Then that row is updated so is_done = TRUE when the user checks the
  task off.

  With immutable facts this would instead be a collection of statements:

  User U added task T with description D at time T1
  User U completed task T at time T2

  To get a list of unfinished tasks for a user, you'd need to grab all
  the tasks from this transaction log, put them into a data structure,
  and then remove ones when you learn that they've been completed.
  Whatever is left over is the todo list.

  Nathan Marz talked about this in terms of big data:

     http://nathanmarz.com/blog/how-to-beat-the-cap-theorem.html

  and Datomic's big bet is that your life as a developer gets much
  easier when you just deal with (entity, attribute, value) + time.

  I buy it in theory, but I have no idea what to expect in terms of
  performance (e.g., how long would it take to find the current todo
  list of someone who has added and completed/removed a few thousand
  items?).

  Has anyone implemented this idea on Clojure datastructures using,
  say,  (timestamp, keyseq, value) and reducing a ton of calls to assoc-
  in?
  Aside from speed, what are some other tradeoffs of an immutable
  approach?

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

 --
 Sent from an IBM Model M, 15 August 1989.

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


(and clojure clodiuno fun)

2012-06-05 Thread eniotna
Hi,

I just wanted to throw a message in the mailing list to THANK all the
clojure dudes out there which does a magnificent job.
Thank you guys.

I'm having fun with it.

It's fun to learn a language which aims to simplify things.

I like to think of Clojure for the developer as the Force to the jedi...
It's way efficient :D

I unfortunately do not use it professionally (i do mainly java dev) but i'm
trying to. Slowly but surely, i use it more and more.
(By the way, I do not know if there are lots of java people here but to
learn or tinker with a new java api, the repl is the tool you must use for
that.)

I also try the best and simply as i can to explain to other people why we
could (must?) use it.

It's kind of hard at times but i do not despair.
It's like the dark ages of say Linux for instance or Lisp, good ideas tend
to take a real long time to spread...

Oh and by the way, i'm beginning to play with http://arduino.cc/en/ and i
use the work https://github.com/nakkaya/clodiuno and
https://github.com/samaaron/serial-port and it's also plain fun. Here's the
result of my tinkering
http://adumont.fr/blog/hello-world-in-morse-with-arduinoclodiuno/

I do not really know where i want to go with this.
Like i said, just plain and simple thank you.

@ardumont

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