Re: Avout: Distributed State in Clojure

2011-11-30 Thread AndyK
If you're willing to dig into another language, 'Erlang and OTP in
Action' gives a great overview of Erlang and the distributed
principles underlying that language. Though different from the
approach of distributed STM, the concepts of distributed applications
are baked into the core of Erlang.

On Nov 30, 2:03 am, Harrison Maseko lis...@gmail.com wrote:
 Could anyone please recommend a good introductory book about
 distributed application development? The release of Avout has gotten
 me interested in the subject.
 Thanks,
 Harrison.

 On Nov 29, 7:38 pm, liebke lie...@gmail.com wrote:







  Today we are releasing Avout, which brings Clojure's in-memory model
  of state to distributed application development by providing a
  distributed implementation of Clojure's Multiversion Concurrency
  Control (MVCC) STM along with distributable, durable, and extendable
  versions of Clojure's Atom and Ref concurrency primitives.

  Here's the post announcing the 
  project:http://clojure.com/blog/2011/11/29/avout.html

  And here's the project's website:http://avout.io

  David

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


ns/use/require/import inconsistent an confusing

2011-11-30 Thread Terje Dahl
Consider the following:

  (ns my.namespace.here)

  (use 'my.namespace.here :reload)

  (require '[my.namespace.here :as something])

  (import [my.package MyClass1 MyClass2])


1.  Why (at least!) 4 different ways of noting namspaces/domains: With
or without the escape-mark (') and with or without square
brackets([])?
Does it have to do with macros vs. functions etc?  Must it be so?
Surely it could be better!


2. Is it stricly necessary to have both use, require, and import
- as well as a host of keywords for the different ones?
Could they perhaps be combined to 2 - or even one?

Dare I say Python seems to have a nice, simple version of a combined
use/require sollution:
  import my.module
  import my.module as m1
  from my.module import MyClass1, MyClass2
  etc.
Cojures require allready allows :as and Clojures use has :only
followed by a list.

And would it be technically possible to:
 I.  Combine a  use/require combined sollution with the import-
function?
 II. Also have a :reload and :reload-all for Java classes?


Is all this a case of that's what me had time for for version 1, but
we are working on something better.?
Or is it technically impossible to improve on or abstract away any of
this?


The  many choices and inconsistencies in the different import-
statements is complicated and confusing.
And as this is the first thing you have to figure out as a new-to-
Clojure programmer (novice or professional) to start programming in
Clojure, it certainly doen't make for a very good first impression!

-- 
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: Avout: Distributed State in Clojure

2011-11-30 Thread Linus Ericsson
In Clojure in Action (still in MEAP i think) there's a chapter about
using (Erlang/OTP-based) RabbitMQ message queue server for making
Clojure scalable in a Hadoopish map-reduce-way.

Avout seems to solve many of the problems that easily could occur in
such an approach by not needing a centralized reduce server for every
calculation.

Another similar way of solving problems of concurrency seems to be
Operational Transformation, which is used in many Google products.

http://en.wikipedia.org/wiki/Operational_transformation

Otherwise +1 for Erlang.

/Linus

On 11/30/11 10:53 AM, AndyK wrote:
 If you're willing to dig into another language, 'Erlang and OTP in
 Action' gives a great overview of Erlang and the distributed
 principles underlying that language. Though different from the
 approach of distributed STM, the concepts of distributed applications
 are baked into the core of Erlang.

 On Nov 30, 2:03 am, Harrison Maseko lis...@gmail.com wrote:
 Could anyone please recommend a good introductory book about
 distributed application development? The release of Avout has gotten
 me interested in the subject.
 Thanks,
 Harrison.

 On Nov 29, 7:38 pm, liebke lie...@gmail.com wrote:







 Today we are releasing Avout, which brings Clojure's in-memory model
 of state to distributed application development by providing a
 distributed implementation of Clojure's Multiversion Concurrency
 Control (MVCC) STM along with distributable, durable, and extendable
 versions of Clojure's Atom and Ref concurrency primitives.
 Here's the post announcing the 
 project:http://clojure.com/blog/2011/11/29/avout.html
 And here's the project's website:http://avout.io
 David

-- 
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: ns/use/require/import inconsistent an confusing

2011-11-30 Thread j1n3l0
Also in a REPL you can do the following:

user (use 'example.core)
nil
user 

But in a source file you have to do:

(ns stuff.core
  (:use 'example.core))

I think I've seen the reason for this difference once before but can 
someone more learned *please* explain :)

Thanks

Nelo

Ps: this exact discussion came up in the London Clojure Dojo last night :)


-- 
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: When are you going to upload Conj2011 videos?

2011-11-30 Thread Doug South
On Wed, Nov 30, 2011 at 12:24 AM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
 Byrd, Friedman, Byrd, Friedman, Byrd, Friedman :)

Was their presentation actually recorded? I don't recall confreaks
being there, but then again, I was too busy watching an excellent
presentation...

-- 
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: When are you going to upload Conj2011 videos?

2011-11-30 Thread Ambrose Bonnaire-Sergeant
Yes!

On Wed, Nov 30, 2011 at 8:12 PM, Doug South doug.so...@gmail.com wrote:

 On Wed, Nov 30, 2011 at 12:24 AM, Ambrose Bonnaire-Sergeant
 abonnaireserge...@gmail.com wrote:
  Byrd, Friedman, Byrd, Friedman, Byrd, Friedman :)

 Was their presentation actually recorded? I don't recall confreaks
 being there, but then again, I was too busy watching an excellent
 presentation...

 --
 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: [ANN] Drift DB

2011-11-30 Thread Luc Prefontaine
Ahem,

considering that I regularly alternate between MySql, Postgres and Oracle 
databases, I like
the idea of just calling a pop menu like Create table (full) and let Aqua 
spit out the DDL in an adjacent window
while having a database explorer pane on the left :)

Memory becomes a pricey real estate after a certain age :)

I use Eclipse/CCW for the same reason, having to navigate in a multilingual 
code base, I cannot see myself
learning different tools for editing purposes or having to remember a 
significant amount of Emacs key shortcuts.

For those that are screaming at me (or laughing ironically), I started using 
Emacs in 1981 on a DEC-20.
This version was written in Teco, extending Emacs was weirder than just dealing 
with a few parenthesis imbrications.

I suspect that some of you were not born yet or were crawling around wearing a 
diaper :)
You will all get there eventually (now I am laughing very loudly :)

Luc

On Wed, 30 Nov 2011 09:54:26 +0200
Michael Wood esiot...@gmail.com wrote:

 Hi
 
 On 29 November 2011 07:03, Luc Prefontaine
 lprefonta...@softaddicts.ca wrote: [...]
  It yields in MySql:
 
  CREATE TABLE meta_entities  (
     id          int(11) NOT NULL,
     name        varchar(255) NOT NULL,
     created_at  datetime NULL,
     updated_at  datetime NULL,
     PRIMARY KEY(id)
  )
  ENGINE = InnoDB
  AUTO_INCREMENT = 0
 
  According to the AquaStudio tool I use to reverse engineer the DDL.
 
 Just by the way, MySQL supports this:
 
 SHOW CREATE TABLE meta_entities\G
 
 No need to reverse engineer the DDL for the tables :)
 



-- 
Luc P.


The rabid Muppet

-- 
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: ns/use/require/import inconsistent an confusing

2011-11-30 Thread jongwon.choi
Even though I've written only one toy web framework in Clojure[1], (I 
think) I know the difference.

Because there is documentation for use and ns, I'll add my own only :)

I interpret (use 'ns) as Use 'ns namespace within *current* namespace - 
from your example, 'user'. Usually for REPL.

(ns ...) is a definition of namespace. You can define any namespace in any 
file, I guess (I didn't try that but it seems it's the right thing to me).

I interpret (ns ns1 (:use 'ns2) as Define ns1 namespace and from ns1 
namespace use stuff in ns2 namespace. Usually for files.

I bet ns is a macro and use 'use' - that's what I'll do. You should try 
macroexpand those things to learn how it works and think such a way. Once 
you have this ability, when you see something new and read doc or usage of 
it, you can imagine if it is function or macro, and (for macro) how 
underlying macroexpansion would look like, etc.

[1]:https://github.com/defstruct/tbw

On Wednesday, 30 November 2011 22:06:04 UTC+11, j1n3l0 wrote:

 Also in a REPL you can do the following:

 user (use 'example.core)
 nil
 user 

 But in a source file you have to do:

 (ns stuff.core
   (:use 'example.core))

 I think I've seen the reason for this difference once before but can 
 someone more learned *please* explain :)

 

-- 
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: ns/use/require/import inconsistent an confusing

2011-11-30 Thread Stuart Sierra
This has been heavily discussed, and some work is underway to mitigate
it.

See http://dev.clojure.org/display/design/Loading%2C+Compiling%2C+and+Namespaces

-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: Drift DB

2011-11-30 Thread Matt
This should now be fixed in version 1.0.6.

-Matt

On Nov 29, 12:03 am, Luc Prefontaine lprefonta...@softaddicts.ca
wrote:
 Hi Matt,

 working with this stuff... pretty sure I can make rake obsolete pretty soon :)

 However I am struggling with the auto increment column attribute...

 (create-table
   :meta-entities
   (integer :id {:not-null true :auto-increment true :primary-key true})
   (string :name {:not-null true :unique true })
   (date-time :created_at)
   (date-time :updated_at))

 which looks to me compliant with what your code does in the mysql flavor lib.

 It yields in MySql:

 CREATE TABLE meta_entities  (
     id          int(11) NOT NULL,
     name        varchar(255) NOT NULL,
     created_at  datetime NULL,
     updated_at  datetime NULL,
     PRIMARY KEY(id)
 )
 ENGINE = InnoDB
 AUTO_INCREMENT = 0

 According to the AquaStudio tool I use to reverse engineer the DDL.

 The trace message:

 DEBUG                   Thread-51 2028 234732,063 drift-db-mysql.flavor ] 
 Create table: :meta-entities with specs: ({:not-null true, :primary-key true, 
 :spec-type :column, :type :integer, :name :id} {:not-null true, :spec-type 
 :column, :type :string, :name :name} {:spec-type :column, :type :date-time, 
 :name :created_at} {:spec-type :column, :type :date-time, :name :updated_at})

 Looks like the :auto-increment is dropped. drift_db/core.clj at line 155 is 
 not selecting
 it as a potential attribute of an integer field.

 I'll patch it locally so I can continue to play with it.

 Any reason why the id type does not accept optional attributes ? I use id 
 auto incremented keys
 everywhere :)

 Thank you,

 Luc

 On Thu, 24 Nov 2011 14:58:43 -0800 (PST)









 Matt macourt...@gmail.com wrote:
  Drift DB is a clojure database library focused on migration functions.

  With Drift DB you can create tables, drop tables, add columns to
  tables, remove columns from tables, query tables, and, though it is
  not the focus of Drift DB, you can insert, update, delete and select
  rows from tables.

  The only databases currently supported are H2 and Mysql. However,
  Drift DB uses a protocol to abstract out database specific code. All
  you would have to do to support other databases is implement the Drift
  DB protocol for it.

  Drift DB, like Drift, was originally a part of Conjure. However, I had
  several requests to separate out the function into their own library.

  Drift DB is not supposed to be a replacement for ClojureQL or Korma.
  Instead, Drift DB is focused on table altering and other tasks usually
  done in Drift migrations. Such tasks are currently not well supported
  in any other Clojure database library.

  All of the code for Drift DB can be found on github at:
 http://github.com/macourtney/drift-db

  Drift DB on Clojars:

  Drift DB Core:http://clojars.org/org.drift-db/drift-db
  Drift DB H2:http://clojars.org/org.drift-db/drift-db-h2
  Drift DB Mysql:http://clojars.org/org.drift-db/drift-db-mysql

 --
 Luc P.

 
 The rabid Muppet

-- 
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: Drift DB

2011-11-30 Thread Luc Prefontaine
Thank you,

Luc

On Wed, 30 Nov 2011 07:18:56 -0800 (PST)
Matt macourt...@gmail.com wrote:

 This should now be fixed in version 1.0.6.
 
 -Matt
 
 On Nov 29, 12:03 am, Luc Prefontaine lprefonta...@softaddicts.ca
 wrote:
  Hi Matt,
 
  working with this stuff... pretty sure I can make rake obsolete
  pretty soon :)
 
  However I am struggling with the auto increment column attribute...
 
  (create-table
    :meta-entities
    (integer :id {:not-null true :auto-increment true :primary-key
  true}) (string :name {:not-null true :unique true })
    (date-time :created_at)
    (date-time :updated_at))
 
  which looks to me compliant with what your code does in the mysql
  flavor lib.
 
  It yields in MySql:
 
  CREATE TABLE meta_entities  (
      id          int(11) NOT NULL,
      name        varchar(255) NOT NULL,
      created_at  datetime NULL,
      updated_at  datetime NULL,
      PRIMARY KEY(id)
  )
  ENGINE = InnoDB
  AUTO_INCREMENT = 0
 
  According to the AquaStudio tool I use to reverse engineer the DDL.
 
  The trace message:
 
  DEBUG                   Thread-51 2028 234732,063
  drift-db-mysql.flavor ] Create table: :meta-entities with specs:
  ({:not-null true, :primary-key
  true, :spec-type :column, :type :integer, :name :id} {:not-null
  true, :spec-type :column, :type :string, :name :name}
  {:spec-type :column, :type :date-time, :name :created_at}
  {:spec-type :column, :type :date-time, :name :updated_at})
 
  Looks like the :auto-increment is dropped. drift_db/core.clj at
  line 155 is not selecting it as a potential attribute of an integer
  field.
 
  I'll patch it locally so I can continue to play with it.
 
  Any reason why the id type does not accept optional attributes ? I
  use id auto incremented keys everywhere :)
 
  Thank you,
 
  Luc
 
  On Thu, 24 Nov 2011 14:58:43 -0800 (PST)
 
 
 
 
 
 
 
 
 
  Matt macourt...@gmail.com wrote:
   Drift DB is a clojure database library focused on migration
   functions.
 
   With Drift DB you can create tables, drop tables, add columns to
   tables, remove columns from tables, query tables, and, though it
   is not the focus of Drift DB, you can insert, update, delete and
   select rows from tables.
 
   The only databases currently supported are H2 and Mysql. However,
   Drift DB uses a protocol to abstract out database specific code.
   All you would have to do to support other databases is implement
   the Drift DB protocol for it.
 
   Drift DB, like Drift, was originally a part of Conjure. However,
   I had several requests to separate out the function into their
   own library.
 
   Drift DB is not supposed to be a replacement for ClojureQL or
   Korma. Instead, Drift DB is focused on table altering and other
   tasks usually done in Drift migrations. Such tasks are currently
   not well supported in any other Clojure database library.
 
   All of the code for Drift DB can be found on github at:
  http://github.com/macourtney/drift-db
 
   Drift DB on Clojars:
 
   Drift DB Core:http://clojars.org/org.drift-db/drift-db
   Drift DB H2:http://clojars.org/org.drift-db/drift-db-h2
   Drift DB Mysql:http://clojars.org/org.drift-db/drift-db-mysql
 
  --
  Luc P.
 
  
  The rabid Muppet
 



-- 
Luc P.


The rabid Muppet

-- 
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: Baltimore Functional Programming

2011-11-30 Thread Gary Trakhman
Awesome, so it looks like there will be enough people to make this happen. 
 I've been in touch with beehive about using their space.  I'm considering 
whether or not to use meetup.com to organize everything, but I think for 
now I'll put together a simple wordpress/google-groups thing and follow-up 
with you guys.  Also, if anyone has any leads on a meeting space, I can 
offer a projector.

-- 
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: Baltimore Functional Programming

2011-11-30 Thread rzeze...@gmail.com
I'm also interested.  I just started to go to beehive occasionally and
I was recently discussing with someone how it would be nice to have a
FP group.  I live in Federal Hill.

On Nov 30, 11:09 am, Gary Trakhman gary.trakh...@gmail.com wrote:
 Awesome, so it looks like there will be enough people to make this happen.
  I've been in touch with beehive about using their space.  I'm considering
 whether or not to use meetup.com to organize everything, but I think for
 now I'll put together a simple wordpress/google-groups thing and follow-up
 with you guys.  Also, if anyone has any leads on a meeting space, I can
 offer a projector.

-- 
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: Drift 1.4.0 released.

2011-11-30 Thread Phil Hagelberg
On Tue, Nov 29, 2011 at 6:13 PM, Matt macourt...@gmail.com wrote:
 1.4.2 is out now and should work with both Clojure 1.2.1 and 1.3.0.
 However, Leiningen currently doesn't work with Clojure 1.3.0.

 At work, I actually have a project.clj with Clojure 1.3.0 in the
 dependencies, and a Clojure 1.2.1 in the dev-dependencies to make
 Leiningen work.

The best thing to do here is to keep the Leiningen plugin in its own
project that runs inside the Leiningen process. Then when you need to
run code in the project itself, use eval-in-project. That way you
don't have to worry about Clojure version mismatches.

-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: Avout: Distributed State in Clojure

2011-11-30 Thread Sean Corfield
On Wed, Nov 30, 2011 at 2:39 AM, Linus Ericsson
oscarlinuserics...@gmail.com wrote:
 In Clojure in Action (still in MEAP i think) there's a chapter about

CiA was officially released at the Conj. Everyone who bought the MEAP
should have had a notification by now about downloading the final
version (my final CiA eBook is dated November 15th).
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

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


Symbol matching in core.match

2011-11-30 Thread Alex Miller
I've been working with core.match some this week and finding it pretty
nice.  However, I have a common case (for me) that is not well handled
right now via core.match: matching symbols. Say that I wrote a match
like this:

;; translate (+ x (+ y z)) to (+ x y z)
(let [e '(+ 1 (+ 2 3))]
  (match [e]
   [([+ x ([+ y z] :seq)] :seq)] (+ x y z)))

You will see this error:
Pattern row 1: Pattern row reuses wildcards in [([+ x ([+ y
z] :seq)] :seq)].  The following wildcards are ambiguous: +.  There's
no guarantee that the matched values will be same.  Rename the
occurrences uniquely.

Any symbol inside a pattern row is treated as a bind variable.  + is a
symbol.  You can achieve this with guards:

(defn +? [s] (= '+ s))

(let [e '(+ 1 (+ 2 3))]
  (match ['(+ 1 (+ 2 3))]
   [([(_o1 :when +?) x ([(_o2 :when +?) y z] :seq)] :seq)] (list
'+ x y z)))

but, yuck.  I can imagine using the reserved ()'s with additional keys
(:symbol or :sym) to do symbol matching like (:symbol +) but also,
yuck.  The simplest idea I came up with was:

(let [e '(+ 1 (+ 2 3))]
  (match [e]
   [(['+ x (['+ y z] :seq)] :seq)] ('+ x y z)))

These come through as (quote x) although the error reporting goes a
little off the rails:
Pattern row 1: Pattern row reuses wildcards in [([(quote +) x ([(quote
+) y z] :seq)] :seq)].  The following wildcards are ambiguous: quote.
There's no guarantee that the matched values will be same.  Rename the
occurrences uniquely.

However, that seems fixable and you could then use (quote x) as a
signal to do symbol matching.  If I can figure out what the hell I'm
doing in core.match then I'd be happy to work on a patch.

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: Symbol matching in core.match

2011-11-30 Thread David Nolen
(quote foo) should be interpreted as a literal match. I thought this was
addressed by a previous user submitted patch but it doesn't look like
that's true.

We currently use seqs as a marker of custom syntax, we dispatch either on
the first or second element of the seq. For example this is how we handle
or:

(defmethod emit-pattern-for-syntax [:or Object]
  [pat] (or-pattern
 (- pat
  (map emit-pattern)
  (into []

So you need to add a new case - [quote Object], and emit a literal pattern.
Feel free to open a ticket in JIRA. Patch welcome!

David

On Wed, Nov 30, 2011 at 2:49 PM, Alex Miller a...@puredanger.com wrote:

 I've been working with core.match some this week and finding it pretty
 nice.  However, I have a common case (for me) that is not well handled
 right now via core.match: matching symbols. Say that I wrote a match
 like this:

 ;; translate (+ x (+ y z)) to (+ x y z)
 (let [e '(+ 1 (+ 2 3))]
  (match [e]
   [([+ x ([+ y z] :seq)] :seq)] (+ x y z)))

 You will see this error:
 Pattern row 1: Pattern row reuses wildcards in [([+ x ([+ y
 z] :seq)] :seq)].  The following wildcards are ambiguous: +.  There's
 no guarantee that the matched values will be same.  Rename the
 occurrences uniquely.

 Any symbol inside a pattern row is treated as a bind variable.  + is a
 symbol.  You can achieve this with guards:

 (defn +? [s] (= '+ s))

 (let [e '(+ 1 (+ 2 3))]
  (match ['(+ 1 (+ 2 3))]
   [([(_o1 :when +?) x ([(_o2 :when +?) y z] :seq)] :seq)] (list
 '+ x y z)))

 but, yuck.  I can imagine using the reserved ()'s with additional keys
 (:symbol or :sym) to do symbol matching like (:symbol +) but also,
 yuck.  The simplest idea I came up with was:

 (let [e '(+ 1 (+ 2 3))]
  (match [e]
   [(['+ x (['+ y z] :seq)] :seq)] ('+ x y z)))

 These come through as (quote x) although the error reporting goes a
 little off the rails:
 Pattern row 1: Pattern row reuses wildcards in [([(quote +) x ([(quote
 +) y z] :seq)] :seq)].  The following wildcards are ambiguous: quote.
 There's no guarantee that the matched values will be same.  Rename the
 occurrences uniquely.

 However, that seems fixable and you could then use (quote x) as a
 signal to do symbol matching.  If I can figure out what the hell I'm
 doing in core.match then I'd be happy to work on a patch.

 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

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

ANN: Tentacles 0.1.0: A Github v3 API library for Clojure

2011-11-30 Thread Anthony Grimes
I just released v0.1.0 of my new Github API library, tentacles.

Tentacles is the successor of my old v2 API library, clj-github. I went 
ahead and rewrote the whole thing because clj-github was a bit of a mess 
and the v3 API is different enough from the v2 API to warrant a new 
library. Also, this one has a better name.

The project is at https://github.com/Raynes/tentacles and Marginalia docs 
are at http://raynes.github.com/tentacles/

Enjoy. :)

-- 
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: noob question about error with tail recursion

2011-11-30 Thread coco
now I'm in a similar trouble...I'm trying  resolve the problem 31 from 
4clojure ...It says:
Write a function which packs consecutive duplicates into sub-lists.
[image: test not run]
(= (__ [1 1 2 1 1 1 3 3]) '((1 1) (2) (1 1 1) (3 3)))

I know than I can use identity and others clojure functions but I wanna 
resolve this using loop too
my idea is it:
I've a mem..this is the final list than I will return and a temporary 
list...
first I compare my first and second item and if these are the same I 
include it in my temp list
if they are different then I include my temp list inside mem (a better name 
would be final_list) and
clear my temp putting the second item in it
I iterate until than my list become empty

the code could be this:


(defn packing [lista]
  (loop [[fst snd  rst] listamem []tmp '(fst)]
(if (seq? lista)
  (if (= fst snd)
(recur (rest lista) mem (cons snd tmp))
(recur (rest lista) (conj mem tmp) (list snd)))
  (seq mem

if I run this I get a java.lang.OutOfMemoryError: Java heap space 
(NO_SOURCE_FILE:0)

It is tail recursive, I'm not sure if I can use 2 distinct recursions 
inside a loop but I think than must be possible..what am I doing wrong??...
thanks so much

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

Can't get the debugger cdt run

2011-11-30 Thread svenali
Hello all,

I try to get the cdt debugger running and fail. I've build the cdt
with leiningen and have this jar file in my classpath. A simple (use
'cdt.break) work. But if I want to use com.georgesjahad.cdt I get the
following error message:

= (use 'com.georgesjahad.cdt)
#FileNotFoundException java.io.FileNotFoundException: Could not
locate com/georgesjahad/cdt__init.class or com/georgesjahad/cdt.clj on
classpath: 

But a
= (use 'cdt.ui)
nil

work.

Where is my problem?

regards,
Sven

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


[ANN] cadr: `car', ..., `cddddr' in Clojure

2011-11-30 Thread Peter Danenberg
Try as I might, I can't purge these anachronisms; so here are `car' to
`cr' in all their glory:

  http://clojars.org/cadr

This implementation uses a Kleene-closure around the alphabet {a, d}
to generate the names; and a macro to define them:

  https://github.com/klutometis/cadr/blob/master/src/cadr/core.clj

-- 
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 can we Laucnh REPL from java Swing application?

2011-11-30 Thread svenali
Hi,

you could do it in a way counterclockwise does. You can implement a
repl that listening at an arbitrary port like doing this:

(ns de.svenali.education.inES.tools.repl
(:require clojure.main)
(:import (java.io InputStreamReader PrintWriter)
  (java.net ServerSocket Socket)
  (clojure.lang LineNumberingPushbackReader))
(:gen-class
  )
)

(defn do-on-thread
   Create a new thread and run function f on it. Returns the thread
object that
was created.
   [f]
   (let [thread (new Thread f)]
  (.start thread)
  thread))

(defn socket-repl
   Start a new REPL that is connected to the input/output streams of
socket.
   [socket]
   (let [socket-in (new LineNumberingPushbackReader
(new InputStreamReader
 (.getInputStream socket)))
   socket-out (new PrintWriter
   (.getOutputStream socket) true)]
  (binding [*in* socket-in
*out* socket-out
*err* socket-out]
(clojure.main/repl

(defn start-repl-server
   Creates a new thread and starts a REPL server on listening on
port. Returns
the server socket that was just created.
   [port]
   (let [server-socket (new ServerSocket port 0)]
  (do-on-thread #(while true (socket-repl (.accept server-
socket
  server-socket))

You have to start this in your swing app. Then you can connect with
standard java sockets to this repl.

regards,
Sven

On 28 Nov., 22:56, Stuart Sierra the.stuart.sie...@gmail.com wrote:
 You can certainly run a REPL in a Swing GUI app. I'm not aware of any
 standalone Swing widgets to do this, but you could look at Clooj for
 an example:https://github.com/arthuredelstein/clooj

 -Stuart Sierra
 clojure.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


Lazy sequence question

2011-11-30 Thread Paweł Łoziński
Hi everybody,

I'd like to create a lazy sequence which has first element x and all
the rest from another lazy sequence. I couldn't find a suitable
function in the docs. Can somebody give a hint?

Best regards
PŁ

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


[newbie] Rebinding a recursive function

2011-11-30 Thread Roman Perepelitsa
Hello,

I'm trying to intercept each call to a recursive function in order to
insert logging. It works on the first invocation but not on others. What am
I missing?

(defn fact [n]
  (if ( n 2)
1
(* n (fact (dec n)

; Given function f, returns another function that
; does the same as f but also prints the arguments.
(defn with-logging [f]
  (fn [ rest]
(do
  (println (str rest))
  (apply f rest

; Factorial that prints its argument on each call.
(defn fact-with-logging [n]
  (binding [fact (with-logging fact)] (fact n)))

; This prints (5) but not (4)...(1). Why?
(fact-with-logging 5)

Roman.

-- 
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: noob question about error with tail recursion

2011-11-30 Thread Chris Perkins
(recur (rest lista) ...)
here:   ^^^

lista is always the same thing. You probably meant (recur (rest rst) ...).

- 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: Symbol matching in core.match

2011-11-30 Thread Steve Miner

On Nov 30, 2011, at 3:04 PM, David Nolen wrote:

 (quote foo) should be interpreted as a literal match. I thought this was 
 addressed by a previous user submitted patch but it doesn't look like that's 
 true.

I wrote a patch that treated quoted keywords as literals so that ':when could 
be used to match a literal :when as opposed to introducing a guard.  Sorry, I 
didn't think about the case of literal symbols.  I assumed they already worked 
that way.  Hmmm, maybe there's a difference between the :seq and vector 
matching.   I will take a look tomorrow to see if I can come up with a patch.

The complaint about reusing symbols is also my contribution.  Maybe match 
bindings should be limited to symbols starting with an alphabetic character.  I 
doubt anyone really wants to bind to symbols that look like operators.  They 
could be treated as literals for the sake of matching.  Any opinions on that?

Steve Miner

-- 
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: noob question about error with tail recursion

2011-11-30 Thread carlos mendez
yep..that is an error but (recur (rest rst) I think wouln't work...maybe
something like

(defn packing [lista]
  (loop [[fst snd :as all] listamem []tmp '(fst)]

   (print all is   all   \n\n) ;;something is wrong...all always is
a empty list

(if (seq? all)
  (if (= fst snd)
(recur (rest all) mem (cons snd tmp))
(recur (rest all) (conj mem tmp) (list snd)))
  (seq mem

something is still wrong..:(



2011/11/30 Chris Perkins chrisperkin...@gmail.com

 (recur (rest lista) ...)
 here:   ^^^

 lista is always the same thing. You probably meant (recur (rest rst) ...).

 - 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: noob question about error with tail recursion

2011-11-30 Thread coco
yep..that is an error but (recur (rest rst) I think wouln't work...maybe 
something like

(defn packing [lista]
  (loop [[fst snd :as all] listamem []tmp '(fst)]

   (print all is   all   \n\n) ;;something is wrong...all always is 
a empty list

(if (seq? all)
  (if (= fst snd)
(recur (rest all) mem (cons snd tmp))
(recur (rest all) (conj mem tmp) (list snd)))
  (seq mem

something is still wrong..:(

-- 
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: Lazy sequence question

2011-11-30 Thread Kasper Galschiot Markus

Is conf what you're looking for?

http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/cons

~Kasper

On 11/30/11 2:27 PM, Paweł Łoziński wrote:

Hi everybody,

I'd like to create a lazy sequence which has first element x and all
the rest from another lazy sequence. I couldn't find a suitable
function in the docs. Can somebody give a hint?

Best regards
PŁ



--
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] Incorporating a database as a source of facts

2011-11-30 Thread Sam Ritchie
Have you guys taken a look at Cascalog? (
https://github.com/nathanmarz/cascalog) It's a datalog implementation in
Clojure that compiles down to MapReduce jobs. Cascalog's host, Cascading,
allows you to pull information from a wide range of datasources (mySQL,
HDFS, ElasticSearch, etc) and might fit your use case.

On Sun, Nov 27, 2011 at 11:40 PM, Tassilo Horn tass...@member.fsf.orgwrote:

 David Nolen dnolen.li...@gmail.com writes:

 Hi David,

  As Mark said you can avoid the graph issue with tabling. core.logic
  has tabling. If you look at the tabling section here -
  https://github.com/clojure/core.logic, you should see something
  related to your problem.

 Thanks, I'll have a look.

  If you do then you should probably just write you own goals that can
  source data from your graph. This can easily be done by returning a
  Choice from your custom goal.
 
  (defn custom-goal [x y z]
 ...
 (choice a (fn [] ...))
 
  choice is like a lazy sequence, you have your first value, and then a
  thunk to produce the remainder of the sequence. You can do whatever
  you want in the body of the custom-goal to make sure the optimal
  resultset is operated on.

 Great, that looks exactly what I need.

 Bye,
 Tassilo
 --
 (What the world needs (I think) is not
  (a Lisp (with fewer parentheses))
  but (an English (with more.)))
 Brian Hayes, http://tinyurl.com/3y9l2kf

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




-- 
Sam Ritchie, Twitter Inc
703.662.1337
@sritchie09

(Too brief? Here's why! http://emailcharter.org)

-- 
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: Symbol matching in core.match

2011-11-30 Thread David Nolen
On Wed, Nov 30, 2011 at 4:29 PM, Steve Miner stevemi...@gmail.com wrote:


 On Nov 30, 2011, at 3:04 PM, David Nolen wrote:

 (quote foo) should be interpreted as a literal match. I thought this was
 addressed by a previous user submitted patch but it doesn't look like
 that's true.


 I wrote a patch that treated quoted keywords as literals so that ':when
 could be used to match a literal :when as opposed to introducing a guard.
  Sorry, I didn't think about the case of literal symbols.  I assumed they
 already worked that way.  Hmmm, maybe there's a difference between the :seq
 and vector matching.   I will take a look tomorrow to see if I can come up
 with a patch.


That would be excellent. Thanks.


 The complaint about reusing symbols is also my contribution.  Maybe match
 bindings should be limited to symbols starting with an alphabetic
 character.  I doubt anyone really wants to bind to symbols that look like
 operators.  They could be treated as literals for the sake of matching.
  Any opinions on that?

 Steve Miner


I'd rather not special case alphanumeric symbols - let's hold off on that.
The complaint about named wildcard reuse is good until we can guarantee
some equality testing behavior.

David

-- 
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] Incorporating a database as a source of facts

2011-11-30 Thread David Nolen
On Wed, Nov 30, 2011 at 4:38 PM, Sam Ritchie sritchi...@gmail.com wrote:

 Have you guys taken a look at Cascalog? (
 https://github.com/nathanmarz/cascalog) It's a datalog implementation in
 Clojure that compiles down to MapReduce jobs. Cascalog's host, Cascading,
 allows you to pull information from a wide range of datasources (mySQL,
 HDFS, ElasticSearch, etc) and might fit your use case.


+1. Though I'm still curious if core.logic offers any benefits for the
simpler use cases :)

David

-- 
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: Symbol matching in core.match

2011-11-30 Thread Alex Miller
Thanks all...

I'm not actually complaining that symbols are taken for bind
variables.  I think in most common match uses that's very natural.
Your suggested change wouldn't actually help me - this was just a
dummy example; in the actual case for me the symbol starts with an
alpha.

If I *were* going to suggest a naming rule to disambiguate bind
variables from symbols, I'd suggest using a leading _ on bind
variables:

;; plus is a symbol to match, _x, _y are variables
(let [e '(plus 2 3)]
  (match [e]
   [([plus _x _y] :seq)] (+ _x _y)))

To me, that gives them a placeholder feel and plays well with the
use of _.  This would break all existing code of course, so I don't
suggest this too seriously. :)

Alex


On Nov 30, 3:29 pm, Steve Miner stevemi...@gmail.com wrote:
 On Nov 30, 2011, at 3:04 PM, David Nolen wrote:

  (quote foo) should be interpreted as a literal match. I thought this was 
  addressed by a previous user submitted patch but it doesn't look like 
  that's true.

 I wrote a patch that treated quoted keywords as literals so that ':when could 
 be used to match a literal :when as opposed to introducing a guard.  Sorry, I 
 didn't think about the case of literal symbols.  I assumed they already 
 worked that way.  Hmmm, maybe there's a difference between the :seq and 
 vector matching.   I will take a look tomorrow to see if I can come up with a 
 patch.

 The complaint about reusing symbols is also my contribution.  Maybe match 
 bindings should be limited to symbols starting with an alphabetic character.  
 I doubt anyone really wants to bind to symbols that look like operators.  
 They could be treated as literals for the sake of matching.  Any opinions on 
 that?

 Steve Miner

-- 
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: Symbol matching in core.match

2011-11-30 Thread David Nolen
On Wed, Nov 30, 2011 at 5:06 PM, Alex Miller a...@puredanger.com wrote:

 ;; plus is a symbol to match, _x, _y are variables
 (let [e '(plus 2 3)]
  (match [e]
   [([plus _x _y] :seq)] (+ _x _y)))

 To me, that gives them a placeholder feel and plays well with the
 use of _.  This would break all existing code of course, so I don't
 suggest this too seriously. :)

 Alex


So you want to use match for matching forms without having to quote
everything?

(let [e '(plus 2 3)]
  (match e
['plus x y] (+ x y)))

To me the above would be ideal. Then it would be trivial for you to write
macro over match say match-syntax which converts from this form:

(let [e '(plus 2 3)]
  (match-syntax e [plus]
(plus x y) (+ x y)))

A quick sketch - kinda syntax-rules-y. Probably something better lurking.

David

-- 
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: Symbol matching in core.match

2011-11-30 Thread Steve Miner
I filed the bug and attached a patch.  The check for duplicate wildcards now 
ignores anything that's quoted.  I'm in a rush so it might be good for others 
to try it out.

http://dev.clojure.org/jira/browse/MATCH-42


Steve Miner
stevemi...@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: noob question about error with tail recursion

2011-11-30 Thread Alan Malloy
(seq? ()) is true. You want (seq all), not (seq? all). There may be
other problems, but that one jumps out at me.

On Nov 30, 1:53 pm, coco clasesparticulares...@gmail.com wrote:
 yep..that is an error but (recur (rest rst) I think wouln't work...maybe
 something like

 (defn packing [lista]
   (loop [[fst snd :as all] lista    mem []    tmp '(fst)]

    (print all is       all   \n\n) ;;something is wrong...all always is
 a empty list

     (if (seq? all)
       (if (= fst snd)
         (recur (rest all) mem (cons snd tmp))
         (recur (rest all) (conj mem tmp) (list snd)))
       (seq mem

 something is still wrong..:(

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


The Clojure way to solve this problem?

2011-11-30 Thread AndyK
I have Clojure code which makes HTTP requests to a server. Depending
on the context, I want to swap out the underlying HTTP library code.
For example, I use an instrumented library in a testing context and a
different library in a REPL context where the instrumented library
will not work. These are low-lying functions - the http/get and http/
put - called within other functions for doing specific kinds of
requests which are called in turn by other functions.

What I'm wondering is what are good ways to dynamically choose which
versions of those low-lying functions to use?

For now, I'm doing this within the namespace that uses the low-lying
functions..

(def get (if (context-flag?) ns.one.http-instrumented/get ns.two.http-
repl/get))

What I don't like about this is that context-flag feeling like a hacky
approach.

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: Symbol matching in core.match

2011-11-30 Thread Alex Miller
That's ok by me.

On Nov 30, 4:16 pm, David Nolen dnolen.li...@gmail.com wrote:

 So you want to use match for matching forms without having to quote
 everything?

 (let [e '(plus 2 3)]
   (match e
     ['plus x y] (+ x y)))

 To me the above would be ideal. Then it would be trivial for you to write
 macro over match say match-syntax which converts from this form:

 (let [e '(plus 2 3)]
   (match-syntax e [plus]
     (plus x y) (+ x y)))

 A quick sketch - kinda syntax-rules-y. Probably something better lurking.

 David

-- 
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: Symbol matching in core.match

2011-11-30 Thread Alex Miller
Ha, I wrote the identical patch locally and it seemed good to me.  So
it gets my ok!

On Nov 30, 5:00 pm, Steve Miner stevemi...@gmail.com wrote:
 I filed the bug and attached a patch.  The check for duplicate wildcards now 
 ignores anything that's quoted.  I'm in a rush so it might be good for others 
 to try it out.

 http://dev.clojure.org/jira/browse/MATCH-42

 Steve Miner
 stevemi...@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: Symbol matching in core.match

2011-11-30 Thread David Nolen
Looks good patch applied.

On Wed, Nov 30, 2011 at 7:24 PM, Alex Miller a...@puredanger.com wrote:

 Ha, I wrote the identical patch locally and it seemed good to me.  So
 it gets my ok!

 On Nov 30, 5:00 pm, Steve Miner stevemi...@gmail.com wrote:
  I filed the bug and attached a patch.  The check for duplicate wildcards
 now ignores anything that's quoted.  I'm in a rush so it might be good for
 others to try it out.
 
  http://dev.clojure.org/jira/browse/MATCH-42
 
  Steve Miner
  stevemi...@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: The Clojure way to solve this problem?

2011-11-30 Thread gaz jones
what about just re-defing the function inside the tests to the
instrumented version?

something like:

(ns one.http)
(defn get [] ...)

(ns one.http-instrumented)
(defn get [] ...)

(ns one.test.blah)
(with-redefs [one.http/get one.http-instrumented/get]
  ...)

guess you could put the redefs into a function and use it as a fixture
if you're using clojure.test? that would get rid of the flag and fork
in the code O_o

On Wed, Nov 30, 2011 at 5:53 PM, AndyK andy.kri...@gmail.com wrote:
 I have Clojure code which makes HTTP requests to a server. Depending
 on the context, I want to swap out the underlying HTTP library code.
 For example, I use an instrumented library in a testing context and a
 different library in a REPL context where the instrumented library
 will not work. These are low-lying functions - the http/get and http/
 put - called within other functions for doing specific kinds of
 requests which are called in turn by other functions.

 What I'm wondering is what are good ways to dynamically choose which
 versions of those low-lying functions to use?

 For now, I'm doing this within the namespace that uses the low-lying
 functions..

 (def get (if (context-flag?) ns.one.http-instrumented/get ns.two.http-
 repl/get))

 What I don't like about this is that context-flag feeling like a hacky
 approach.

 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

-- 
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: The Clojure way to solve this problem?

2011-11-30 Thread mmwaikar
I think you should look at the binding function - 
http://clojuredocs.org/clojure_core/clojure.core/binding

In my tests, I am using this to run the same tests using two different 
functions, which are supposed to do the same thing (using two different 
methods, internally).

In your case though, you might need a way to figure out in which context is 
it running (to be able to change the bindings).

HIH,
Manoj.

-- 
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: The Clojure way to solve this problem?

2011-11-30 Thread Baishampayan Ghose
 I think you should look at the binding function -
 http://clojuredocs.org/clojure_core/clojure.core/binding

 In my tests, I am using this to run the same tests using two different
 functions, which are supposed to do the same thing (using two different
 methods, internally).

 In your case though, you might need a way to figure out in which context is
 it running (to be able to change the bindings).

`binding` won't work in 1.3 because function vars are not dynamic.
`with-redefs` is the right way to do it now.

Regards,
BG

-- 
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: [ANN] cadr: `car', ..., `cddddr' in Clojure

2011-11-30 Thread Tassilo Horn
Peter Danenberg pe...@factual.com writes:

Hi Peter,

 Try as I might, I can't purge these anachronisms; so here are `car' to
 `cr' in all their glory:

   http://clojars.org/cadr

Nice. :-)

 This implementation uses a Kleene-closure around the alphabet {a, d}
 to generate the names; and a macro to define them:

   https://github.com/klutometis/cadr/blob/master/src/cadr/core.clj

Is that inspired by the `cxr' macro (I think, that was its name) in Let
Over Lambda?  One nice feature that seems missing from your version is a
macro for defining local functions on demand.  I don't remember the
exact LoL syntax, but probably it would look something like that:

(with-cxrs [foo caaaddaddr,
bar car]
  (cons (foo myseq) (bar mysec)))

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