Re: clj-ldap

2011-11-04 Thread Saul Hazledine
Hello  George,

You can use the bind? function in this fork of clj-ldap:

https://github.com/pauldorman/clj-ldap

Saul

On Nov 4, 2:03 am, gtasso  wrote:
> I am very new in Clojure. I'd like someone to how an example code on
> how we can authenticate users on a windows server using clj-ldap
> library.
>
> Best,
>
> George Tasso.

-- 
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: Please try the alphas and betas!

2011-11-04 Thread John Szakmeister
On Wed, Nov 2, 2011 at 10:00 AM, Chas Emerick  wrote:
[snip]
> Yes; this is called "locking" snapshots in the Maven world, and there are 
> commands there that can lock any snapshot dependencies to the current 
> snapshot.
>
> If you are using Leiningen, there are no corollary commands, but you can use 
> the same concrete snapshot version numbers.  e.g. looking at Clojure 1.4.0 
> snapshots here:
>
> https://oss.sonatype.org/content/repositories/snapshots/org/clojure/clojure/1.4.0-master-SNAPSHOT/
>
> You can use a version number like "1.4.0-master-20111025.230825-6" to fix 
> against that particular snapshot instead of continually updating to HEAD.
>
> That said, if alphas are going to be emitted at a steady pace, then updating 
> to them as desired may suit your use case better (i.e. it's easier to know to 
> revert to -alpha8 [or whatever] than it is to revert to 
> 1.4.0-master-20111025.230825-6).
>
> The maven snapshot metadata is only maintained for the latest snapshot so 
> version numbers that include SNAPSHOT can resolve to a particular concrete 
> artifact. Explicitly using a concrete snapshot version (like 
> "1.4.0-master-20111025.230825-6") resolves directly to the artifact in 
> question, so the metadata isn't relevant.

Thanks to all who responded!  This is really good to know.

-John

-- 
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: -> vs ->> and names vs anonymous function

2011-11-04 Thread Stefan Kamphausen
Thanks for pointing my error out.  I was not only oversimplifying things, 
worse, I simplified something away that was crucial to the original 
question.

Regards
Stefan

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure-refactoring - what's the best way to distribute a clojure + emacs/elisp combined package?

2011-11-04 Thread Joost
I've implemented Phil's suggestion of using swank_elisp_payloads, and
version 0.6.3 of clojure-refactoring is available right now as a
leiningen plugin:

lein plugin install joodie/clojure-refactoring 0.6.3

The clojure-refactoring Emacs functions will then be available under C-
c C-f whenever you run clojure-jack-in to start a SLIME session.

For more info, see the readme at https://github.com/joodie/clojure-refactoring

Thanks!
Joost.

-- 
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: Korma - a SQL DSL for Clojure

2011-11-04 Thread Stathis Sideris
Very nice, thanks Chris!

Is there any way to use this to group together a bunch of SQL
statements as a transaction?

By the way, I think the colour scheme of the website is great, it does
really remind me of korma sauce!

Stathis


On Nov 4, 3:15 am, Daniel  wrote:
> Good color choices on the website.  It would be interesting to see
> some performance comparisons between korma and clojureql, but I don't
> really know what kinds of tests would make for good benchmarks.  From
> what I read c3po is the preferred way to do connection pooling (I had
> been configuring clj-dbcp), so kudos on that.  I've never used c3po
> before, but it looks like there's a config file which gives more
> flexibility than the connection-pool function - is there any ceremony
> involved in making korma use the c3po config file?
>
> Also, why use the log4j stuff directly and not tools.logging?  Don't
> take this the wrong way.  I want to know if there would be any salient
> advantage to use it in one of my projects.
>
> On Nov 3, 12:13 am, Chris Granger  wrote:
>
>
>
>
>
>
>
> > Color is always a touchy and very subjective realm. :)
>
> > In terms of "why not ClojureQL?" I'll quote my response from HN:
>
> > The issue I had with ClojureQL is that it seems like the wrong abstraction
> > to me. Myself and others I've talked to have found ourselves fighting with
> > how it tries to model data and more specifically the kind of queries it
> > generates. For example, it is very quick to use rather inefficient
> > sub-selects.
>
> > Cheers,
> > Chris.
>
> > On Wed, Nov 2, 2011 at 5:45 PM, Carin Meier  wrote:
> > > I really like the color pallette :)
>
> > > --
> > > 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: Introspecting functions

2011-11-04 Thread Stathis Sideris
Although it doesn't directly answer your question, I have used (with-
meta) to attach debug information to generated functions in the past.
If you are writing function combinators you can even do this
recursively by taking the existing debug info from a function that you
generated before and combine it new debug info for the function you
are currently generating.

For an actual example on how to do this, see (and-matcher) and the
surrounding matcher functions here:

https://github.com/stathissideris/clarity/blob/master/src/clarity/structure.clj

Stathis


On Nov 3, 9:59 pm, AndyK  wrote:
> Is it possible to print information about a function from within the
> repl? For example, after using comp or partial to create new
> functions, can you display the arity, the source, etc? I'm trying to
> debug a problem and it would be handy to be able to check that my
> dynamic funcitons are what I think they are.
>
> thx

-- 
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: Which autodoc dep for clojure 1.3 (and advice on how to solve such questions generally)

2011-11-04 Thread Hubert Iwaniuk

Hi Phil,

With "Leiningen 1.6.1.1 on Java 1.6.0_26 Java HotSpot(TM) 64-Bit Server VM" 
executing:
$ lein plugin install audodoc 0.7.1
fails advising to download artifact by hand.
Though searching for it:
$ lein search "autodoc AND NOT g:org.clojars*"
Shows line with:
[autodoc "0.7.1"] A tool to build HTML documentation from your Clojure source

Could it be that somehow metadata is not in sync with content of repository?

Currently I'm not able to get autodoc running at all :(

Cheers,
Hubert.

Phil Hagelberg wrote:

On Wed, Nov 2, 2011 at 2:09 PM, Craig Brozefsky  wrote:

I am making a project that uses clojure 1.3, and I want to use autodoc,
and I'm not sure which dependency line should be in my project.clj.


Things like autodoc are usually best installed as user-level plugins,
so stick with "lein plugin install $FOO $VERSION". To find the right
version, usually your best bet is something like:

 $ lein search "autodoc AND NOT g:org.clojars*"


So, I'm asking for a suggested dep for that, but also I am wondering
what is the standard operating procedure for resolving such dependency
issues.  Is there some Maven black magick I should familiarize myself
with in order to list packages and their deps?


If you're interested in a full transitive dependency listing, you
actually need Maven:

 $ lein pom&&  mvn dependency:tree

I hope to port that to lein at some point as it's fantastically useful.

-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


conditional get with feedparser-clj (or another RSS feed parser)?

2011-11-04 Thread George Oliver
hi,

I'm making a site similar to clojurls.com (a more dynamic version of
my old site ifurls.tumblr.com), so I'm working with feedparser-clj
[1].

It doesn't look like feedparser currently wraps the conditional get
from RomeFetcher [2], so I'm wondering if there is a Clojure library
that does provide something similar, or what the best course might be
-- wrap it myself, use RomeFetcher directly, or use something else.

I'm new to Clojure and Java so I'd like some advice beforehand.

thanks, George


[1] https://github.com/vgeshel/feedparser-clj
[2] http://wiki.java.net/twiki/bin/view/Javawsxml/RomeFetcher

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


Adding forms to fn

2011-11-04 Thread N8Dawgrr
Hi Clojure Group,

I'm new to the group, apologies if this topic has been raised before.
Basically I'm wondering if there is a reason why the form used to
defined a function isn't attached as meta-data to the function.
Clojure is a isomorphic language and this capability would really help
me out with some libraries I'm building.

Clojure forms are pretty compact, much smaller than the compiled byte-
code, I can't see it having a big impact on the memory footprint.

People might argue that I could provide a local fn macro which
captures the form meta-data and calls the clojure.core/fn macro to do
the real work. The problem with this approach is that the reader macro
#(%) expands to fn*. There is no way of overriding the fn* symbol.

What are peoples 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: ANN: Korma - a SQL DSL for Clojure

2011-11-04 Thread mnicky
on my laptop the colors are nice and readable, but on my better IPS monitor 
the page is not looking very well and reads a _lot_ harder, almost causing 
pain in my eyes ;-)

...so when designing site with uncommon color schemes, I suggest trying it 
on more, different types of monitors...

But Korma itself seems really good :-)

-- 
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: Simple Made Easy - Any Examples?

2011-11-04 Thread Gary Trakhman
I think it's probably harder to actually show 'best practice' in a lisp 
than say a language like java.  The notion of a design pattern can always 
be abstracted away with functions or macros.  So, the examples I've seen so 
far are very small scale, eg: use lazy seqs and function composition 
instead of loop/recur, that kind of thing.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure-refactoring - what's the best way to distribute a clojure + emacs/elisp combined package?

2011-11-04 Thread Chas Emerick

On Nov 3, 2011, at 6:14 PM, Joost wrote:

> 
> 
> On Nov 3, 10:52 pm, Chas Emerick  wrote:
>> Joost,
>> 
>> This looks great.  I think I might have been vaguely aware of 
>> clojure-refactoring before, but I'm glad to have been reminded of it.
>> 
>> Q: how much of it is Emacs/SLIME specific?
>> 
>> I ask because I'd love to see the advertised functionality rolled into 
>> Counterclockwise (and any other Clojure tooling out there).  Such common 
>> tooling libraries were contemplated here, FWIW:
>> 
>> http://dev.clojure.org/display/design/IDE+tooling+backend
>> 
>> …though there's no refactoring section there (yet, *hint* ;-)
> 
> I was sort of expecting this question :)
> 
> Much of the code is actually editor-agnostic; the real refactoring
> code is all pure clojure and implements its own parser/generator. The
> main API requires an interface that can recognize clojure expressions/
> def forms and pass them as strings.
> 
> The actual communication with the editor is done over the SLIME
> protocol, but aside from the global rename refactoring, which needs to
> touch files all over a project, it doesn't seem to be too complex
> (mostly because it's sending the code as strings instead of trying to
> be clever with s-expressions).
> 
> As far as I can see, it's definitely possible to split out the editor-
> agnostic parts of the code into its own package, and I expect that
> would be useful for more than just refactoring tools too; automated
> code formatting would be another possible use for one.
> 
> I'd be willing to put some work into making the code more accessible
> to other editors/programs, but I'm not personally motivated to develop
> and maintain any bindings for editors other than Emacs right now. I
> don't have the time to learn how to use them or to test any issues
> that may turn up on those systems.
> 
> In other words; somebody else has to be willing to take up the work of
> binding the basic refactoring code to their editor of choice (and
> maintain the bindings!) but if someone is willing to do that, I'm
> willing to make their usage of the clojure-refactoring code as
> painless as reasonable.

I've only looked at the code for ~5 minutes, but I think I might understand 
what's going on.  To confirm: clojure-refactoring is sending something like 
diffs back to the refactoring-mode/SLIME, and that mode/emacs is what is 
actually performing the modifications to affected files?

Thanks,

- Chas

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure-refactoring - what's the best way to distribute a clojure + emacs/elisp combined package?

2011-11-04 Thread Laurent PETIT
Hello,

As far as I remember, clojure-refactoring considered (or is using ?)
using parsley + the clojure grammar in paredit.clj for some (all ?) of
its refactorings.

What is the current status of this ? (I also have a long delayed todo
list note on adding refactoring to CCW, for sure ! :-) )

2011/11/3 Chas Emerick :
> Joost,
>
> This looks great.  I think I might have been vaguely aware of 
> clojure-refactoring before, but I'm glad to have been reminded of it.
>
> Q: how much of it is Emacs/SLIME specific?
>
> I ask because I'd love to see the advertised functionality rolled into 
> Counterclockwise (and any other Clojure tooling out there).  Such common 
> tooling libraries were contemplated here, FWIW:
>
> http://dev.clojure.org/display/design/IDE+tooling+backend
>
> …though there's no refactoring section there (yet, *hint* ;-)
>
> - Chas
>
> On Nov 3, 2011, at 5:32 PM, Joost wrote:
>
>> As some of you may know, I've recently taken over maintenance of the
>> clojure-refactoring package for doing simple refactorings in Emacs/
>> SLIME with clojure-mode.
>>
>> This package consists of a bunch of clojure code that does the actual
>> refactoring, plus an elisp file that handles the editor/ui side of
>> things. I'm working on making the whole package more reliable and one
>> of the obvious issues right now is that installation is a two-step
>> process that may be intimidating to new users - especially those
>> people who don't have a lot of experience customizing their Emacs
>> setup.
>>
>> Ideally, what I would like to end up with is a single-step, no-fuss
>> install process, but I'm unsure how to best get there. Leiningen/cake
>> based installs are good, provide the clojure dependencies and
>> generally work fine, so I'm going with clojars right now, but users
>> still need to extract/download the elisp code separately and keep it
>> in sync with the clojure code. Which is annoying and intimidating to
>> people new to Emacs.
>>
>> Marmalade packages for elisp also work fine but as far as I can see,
>> you can't easily include clojure jars with marmalade packages and also
>> make them work "out of the box" with SLIME.
>>
>> The most straight-forward solution I can think of right now is to
>> split the package in half; put the elisp code on marmalade and provide
>> a clojars jar for use as a leiningen plugin/project dependency, but if
>> anyone can think of a reasonable way of making things simpler than
>> that for the end-users, I would appreciate any suggestions. I think it
>> would make a lot of probably already overwhelmed new Emacs / Clojure
>> users feel a little less intimidated. :)
>>
>> Please let me know what you think is a good idea.
>> Thanks in advance,
>> Joost Diepenmaat.
>>
>>
>> References:
>>
>> clojure-refactoring page: https://github.com/joodie/clojure-refactoring
>> Clojars pom/lein info: http://clojars.org/joodie/clojure-refactoring
>>
>> --
>> 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: Simple Made Easy - Any Examples?

2011-11-04 Thread David Nolen
Look at the sources for ClojureScript, Ring, Clache.

David

On Sun, Oct 30, 2011 at 9:23 PM, aboy021  wrote:

> I very much enjoyed Rich's talk on Simple Made Easy (http://
> www.infoq.com/presentations/Simple-Made-Easy). It seemed to address a
> great many of the frustrations I have in software development and
> offer real hope of being able to do things better.
>
> The things is, it would be really nice to have some code that
> exemplifies the approaches the were talked about. I've seen posts on
> this group before as well as on StackOverflow talking about the need
> for an example application in Clojure of medium size that shows off
> best practice, and I echo that desire.
>
> Perhaps just an html page based on slide 25 of Rich's talk: "The
> Simplicity Toolkit" with columns labeled "Construct" and "Get it
> via...". The page could have links on the "Get it via..." side to
> pages with more detail and examples.
>
> --
> 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

Korma - cannot acquire connections

2011-11-04 Thread AndyK
I believe I have setup korma correctly with
(require '[korma.db :as db])
(require '[korma.core :as sql])
(db/defdb devdb (db/mysql {:db "mydb" :host "localhost" :user
"me" :password "mypass"}))
(sql/defentity mytable
(sql/select mytable (sql/fields :id) (sql/where {:id 1})))

But I'm getting
SQLException:
 Message: Connections could not be acquired from the underlying
database!
 SQLState: null
 Error Code: 0

(db/get-connection devdb) returns a clojure.lang.PersistentHashMap -
is that right? or should it be the underlying java.sql.Connection?

I have the mysql driver in my classpath, am able to Class/forName the
driver, create a connection, and query on the connection - all
manually. Korma looks pretty cool and I'd like to be using, any ideas?

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


Update swank classpath on the fly?

2011-11-04 Thread AndyK
I've noticed that swank (which I run in emacs using M-x clojure-jack-
in) doesn't pickup changes to the classpath on-the-fly. For example,
if I update my leiningen project.clj with a new dependency and run
lein deps, I need to restart swank to have it use the library. Is
there a way to load something into a running swank without restarting
it (which causes loss of state in the slime-repl).

thx

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure Conj extracurricular activities spreadsheet

2011-11-04 Thread Gary Trakhman
I can offer my personal projector if it's needed.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure Conj extracurricular activities spreadsheet

2011-11-04 Thread David Nolen
Wow that would be awesome!

On Fri, Nov 4, 2011 at 12:13 PM, Gary Trakhman wrote:

> I can offer my personal projector if it's needed.
>
> --
> 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: Update swank classpath on the fly?

2011-11-04 Thread Jack Moffitt
> I've noticed that swank (which I run in emacs using M-x clojure-jack-
> in) doesn't pickup changes to the classpath on-the-fly. For example,
> if I update my leiningen project.clj with a new dependency and run
> lein deps, I need to restart swank to have it use the library. Is
> there a way to load something into a running swank without restarting
> it (which causes loss of state in the slime-repl).

I have the same project, which I suspect is a limitation of the JVM.
I'd settle for a fast way to restart the session.

jack.

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


a better way to write this

2011-11-04 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

here's a part of my clojureoids-code:

  (let [type-pred #()
bounds-check #()
contact #()
full-test (fn [element] (and (type-pred element) (bounds-check
element) (contact element)))]
  (filter full-test (:game-elements @world-atom))

is there a way to write the full-test in a way that doesn't force me
to repeat the "function " pattern inside the and?


-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOtBgfAAoJENRtux+h35aGDTAP/RM2mXcu7+HlH0gVHPcZ2bH0
31MEGk5ysup06vgntmxOClaNV9PcxQ1g3bu44YTWDKy3S5RWiD+yB+LkAV0e8xvM
p8A64giicfaxI2qncmEpgjodrUn8Yg4vde9X5pQRRaQaWTG56jlLUClorOy62W2q
gsvNaehEZa6MZiG6yQOEQ1j0sS438bkmCsqxmHAs2ZmAkb9osTatKECK4sAZRx6l
31KHRFEWx8piiND5vxUGeqlf/CHC3r9VCgBc86q/nnH2CL4cofrkv6mXUYxHikPS
AVbT8Qtuonh+twoGLH6t+TYCrVIgiAmnO9IOWFqpdkcX+us3V+ETvXSAVfuf6mCM
+pS3Ps0+VndU31/ufZ0pdki/DxlMJiMVPSS1l/Z76671rCQe+dBjFDSU4e+4y9du
sj0h1VNQ/tKzQ0jCGb9AF6MHoy51b4dpaqjwuJ4HQscH3L9ruG46dTZs5+IvWb5v
2htp5jQNY25e05qbT2tjPVTKT7C6kZ5S3dMlAfQnQxIaHrIm92IHzq3bhF3xMbgy
Yh5sC66y/O4BPZnCvcKY6RF6wBlSZ/vLVOYAasvV89bWanUvv5vgFlNWysNoNF0o
eCFhm1NQmvDoqTa0okx3kN5LeoVgGZdfmkEcVNIvVNUFYzht6ffGNaESb3YWFMlO
buElt55CDSzWlvkBwqPU
=A6jg
-END PGP SIGNATURE-

-- 
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: a better way to write this

2011-11-04 Thread Timothy Baldridge
Using collections:

(every? true? (map #(%1 %2) [func1 func2] (repeat common-argument)))

where func1 func2 are your functions. and common-argument is the
argument shared by them all.

Or something like this:

(every? true? (map #(%1 %2) [type-pred bounds-check contact] (repeat element)))

Granted this won't be the fastest method in the world (macros would
probably be better), as there's going to be a fair amount of object
creation going on, and now instead of invoking 3 functions, we're
invoking much more. But at least this code is readable, and fairly
easy to understand.

Timothy

On Fri, Nov 4, 2011 at 11:51 AM, Dennis Haupt  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> here's a part of my clojureoids-code:
>
>  (let [type-pred #()
>        bounds-check #()
>        contact #()
>        full-test (fn [element] (and (type-pred element) (bounds-check
> element) (contact element)))]
>  (filter full-test (:game-elements @world-atom))
>
> is there a way to write the full-test in a way that doesn't force me
> to repeat the "function " pattern inside the and?
>
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.14 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQIcBAEBAgAGBQJOtBgfAAoJENRtux+h35aGDTAP/RM2mXcu7+HlH0gVHPcZ2bH0
> 31MEGk5ysup06vgntmxOClaNV9PcxQ1g3bu44YTWDKy3S5RWiD+yB+LkAV0e8xvM
> p8A64giicfaxI2qncmEpgjodrUn8Yg4vde9X5pQRRaQaWTG56jlLUClorOy62W2q
> gsvNaehEZa6MZiG6yQOEQ1j0sS438bkmCsqxmHAs2ZmAkb9osTatKECK4sAZRx6l
> 31KHRFEWx8piiND5vxUGeqlf/CHC3r9VCgBc86q/nnH2CL4cofrkv6mXUYxHikPS
> AVbT8Qtuonh+twoGLH6t+TYCrVIgiAmnO9IOWFqpdkcX+us3V+ETvXSAVfuf6mCM
> +pS3Ps0+VndU31/ufZ0pdki/DxlMJiMVPSS1l/Z76671rCQe+dBjFDSU4e+4y9du
> sj0h1VNQ/tKzQ0jCGb9AF6MHoy51b4dpaqjwuJ4HQscH3L9ruG46dTZs5+IvWb5v
> 2htp5jQNY25e05qbT2tjPVTKT7C6kZ5S3dMlAfQnQxIaHrIm92IHzq3bhF3xMbgy
> Yh5sC66y/O4BPZnCvcKY6RF6wBlSZ/vLVOYAasvV89bWanUvv5vgFlNWysNoNF0o
> eCFhm1NQmvDoqTa0okx3kN5LeoVgGZdfmkEcVNIvVNUFYzht6ffGNaESb3YWFMlO
> buElt55CDSzWlvkBwqPU
> =A6jg
> -END PGP SIGNATURE-
>
> --
> 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



-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

-- 
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: a better way to write this

2011-11-04 Thread Benny Tsai
This is slightly shorter:

full-test (fn [element] (every? #(% element) [type-pred bounds-check 
contact]))

On Friday, November 4, 2011 10:51:43 AM UTC-6, HamsterofDeath wrote:
>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> here's a part of my clojureoids-code:
>
>   (let [type-pred #()
> bounds-check #()
> contact #()
> full-test (fn [element] (and (type-pred element) (bounds-check
> element) (contact element)))]
>   (filter full-test (:game-elements @world-atom))
>
> is there a way to write the full-test in a way that doesn't force me
> to repeat the "function " pattern inside the and?
>
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.14 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQIcBAEBAgAGBQJOtBgfAAoJENRtux+h35aGDTAP/RM2mXcu7+HlH0gVHPcZ2bH0
> 31MEGk5ysup06vgntmxOClaNV9PcxQ1g3bu44YTWDKy3S5RWiD+yB+LkAV0e8xvM
> p8A64giicfaxI2qncmEpgjodrUn8Yg4vde9X5pQRRaQaWTG56jlLUClorOy62W2q
> gsvNaehEZa6MZiG6yQOEQ1j0sS438bkmCsqxmHAs2ZmAkb9osTatKECK4sAZRx6l
> 31KHRFEWx8piiND5vxUGeqlf/CHC3r9VCgBc86q/nnH2CL4cofrkv6mXUYxHikPS
> AVbT8Qtuonh+twoGLH6t+TYCrVIgiAmnO9IOWFqpdkcX+us3V+ETvXSAVfuf6mCM
> +pS3Ps0+VndU31/ufZ0pdki/DxlMJiMVPSS1l/Z76671rCQe+dBjFDSU4e+4y9du
> sj0h1VNQ/tKzQ0jCGb9AF6MHoy51b4dpaqjwuJ4HQscH3L9ruG46dTZs5+IvWb5v
> 2htp5jQNY25e05qbT2tjPVTKT7C6kZ5S3dMlAfQnQxIaHrIm92IHzq3bhF3xMbgy
> Yh5sC66y/O4BPZnCvcKY6RF6wBlSZ/vLVOYAasvV89bWanUvv5vgFlNWysNoNF0o
> eCFhm1NQmvDoqTa0okx3kN5LeoVgGZdfmkEcVNIvVNUFYzht6ffGNaESb3YWFMlO
> buElt55CDSzWlvkBwqPU
> =A6jg
> -END PGP SIGNATURE-
>
>

-- 
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: Update swank classpath on the fly?

2011-11-04 Thread Chas Emerick

On Nov 4, 2011, at 11:53 AM, AndyK wrote:

> I've noticed that swank (which I run in emacs using M-x clojure-jack-
> in) doesn't pickup changes to the classpath on-the-fly. For example,
> if I update my leiningen project.clj with a new dependency and run
> lein deps, I need to restart swank to have it use the library. Is
> there a way to load something into a running swank without restarting
> it (which causes loss of state in the slime-repl).
> 
> thx

This is part of what pomegranate provides:

https://github.com/cemerick/pomegranate

It won't pick up changes from your project.clj, but it does provide an 
`add-dependencies` function that works with leiningen-style dependency notation 
(and an improved `add-classpath` if you just have jars available on disk you 
want to dynamically add to your classpath).

However, I have at least one report that pomegranate fails under swank:

https://github.com/cemerick/pomegranate/issues/1

It'd be great to get confirmation or not of that issue (or, even better, a 
patch to make it work under swank!).  FWIW, it works fine in a command-line 
REPL and with nREPL (jark, counterclockwise).  I've yet to test it with 
swank/slime myself.

Cheers,

- Chas

-- 
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: a better way to write this

2011-11-04 Thread Paul Mooser
You could try using "every-pred" to combine your predicates, which I
think would be equivalent:

(let [full-test (every-pred type-pred bounds-check contact)]
   ...

On Nov 4, 9:51 am, Dennis Haupt  wrote:
>   (let [type-pred #()
>         bounds-check #()
>         contact #()
>         full-test (fn [element] (and (type-pred element) (bounds-check
> element) (contact element)))]
>   (filter full-test (:game-elements @world-atom))
>
> is there a way to write the full-test in a way that doesn't force me
> to repeat the "function " pattern inside the and?

-- 
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: a better way to write this

2011-11-04 Thread Benny Tsai
Oh that is cool!

On Friday, November 4, 2011 12:11:43 PM UTC-6, Paul Mooser wrote:
>
> You could try using "every-pred" to combine your predicates, which I 
> think would be equivalent: 
>
> (let [full-test (every-pred type-pred bounds-check contact)] 
>... 
>
> On Nov 4, 9:51 am, Dennis Haupt  wrote: 
> >   (let [type-pred #() 
> > bounds-check #() 
> > contact #() 
> > full-test (fn [element] (and (type-pred element) (bounds-check 
> > element) (contact element)))] 
> >   (filter full-test (:game-elements @world-atom)) 
> > 
> > is there a way to write the full-test in a way that doesn't force me 
> > to repeat the "function " pattern inside the and? 
>

-- 
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: Korma - cannot acquire connections

2011-11-04 Thread Base
Did you mean to define the select within the defentity?

(sql/defentity mytable    (sql/select mytable (sql/fields :id) (sql/
where {:id 1})))

I does this work?

(sql/defentity mytable
  (:pk <<< YOUR PRIMARY KEY AS A KEYWORD>>>)
  (table <<>>)
 (database devdb))

(sql/select mytable (sql/fields :id) (sql/where {:id 1}))

On Nov 4, 10:44 am, AndyK  wrote:
> I believe I have setup korma correctly with
> (require '[korma.db :as db])
> (require '[korma.core :as sql])
> (db/defdb devdb (db/mysql {:db "mydb" :host "localhost" :user
> "me" :password "mypass"}))
> (sql/defentity mytable
> (sql/select mytable (sql/fields :id) (sql/where {:id 1})))
>
> But I'm getting
> SQLException:
>  Message: Connections could not be acquired from the underlying
> database!
>  SQLState: null
>  Error Code: 0
>
> (db/get-connection devdb) returns a clojure.lang.PersistentHashMap -
> is that right? or should it be the underlying java.sql.Connection?
>
> I have the mysql driver in my classpath, am able to Class/forName the
> driver, create a connection, and query on the connection - all
> manually. Korma looks pretty cool and I'd like to be using, any ideas?

-- 
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: Korma - cannot acquire connections

2011-11-04 Thread Base
Actually it should read:

(sql/defentity mytable
  (:pk <<< YOUR PRIMARY KEY AS A KEYWORD>>>)
  (sql/table <<>>)
  (sql/database devdb))

(sql/select mytable (sql/fields :id) (sql/where {:id 1}))



On Nov 4, 3:21 pm, Base  wrote:
> Did you mean to define the select within the defentity?
>
> (sql/defentity mytable    (sql/select mytable (sql/fields :id) (sql/
> where {:id 1})))
>
> I does this work?
>
> (sql/defentity mytable
>   (:pk <<< YOUR PRIMARY KEY AS A KEYWORD>>>)
>   (table <<>>)
>  (database devdb))
>
> (sql/select mytable (sql/fields :id) (sql/where {:id 1}))
>
> On Nov 4, 10:44 am, AndyK  wrote:
>
>
>
>
>
>
>
> > I believe I have setup korma correctly with
> > (require '[korma.db :as db])
> > (require '[korma.core :as sql])
> > (db/defdb devdb (db/mysql {:db "mydb" :host "localhost" :user
> > "me" :password "mypass"}))
> > (sql/defentity mytable
> > (sql/select mytable (sql/fields :id) (sql/where {:id 1})))
>
> > But I'm getting
> > SQLException:
> >  Message: Connections could not be acquired from the underlying
> > database!
> >  SQLState: null
> >  Error Code: 0
>
> > (db/get-connection devdb) returns a clojure.lang.PersistentHashMap -
> > is that right? or should it be the underlying java.sql.Connection?
>
> > I have the mysql driver in my classpath, am able to Class/forName the
> > driver, create a connection, and query on the connection - all
> > manually. Korma looks pretty cool and I'd like to be using, any ideas?

-- 
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: a better way to write this

2011-11-04 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

my favorite :)
thx

Am 04.11.2011 20:32, schrieb Benny Tsai:
> Oh that is cool!
> 
> On Friday, November 4, 2011 12:11:43 PM UTC-6, Paul Mooser wrote:
> 
> You could try using "every-pred" to combine your predicates, which
> I think would be equivalent:
> 
> (let [full-test (every-pred type-pred bounds-check contact)] ...
> 
> On Nov 4, 9:51 am, Dennis Haupt  wrote:
>> (let [type-pred #() bounds-check #() contact #() full-test (fn
>> [element] (and (type-pred element)
> (bounds-check
>> element) (contact element)))] (filter full-test (:game-elements
>> @world-atom))
>> 
>> is there a way to write the full-test in a way that doesn't force
>> me to repeat the "function " pattern inside the
>> and?
> 
> -- 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


- -- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOtE78AAoJENRtux+h35aGS7EP/ihZ8EgpG4q6WTNuzeBLsBg8
sv+etYJByD+EWg03cIWM5mop1i7YfqslOcg3nZCj7DrFYud9kCxDlxa2fTc6wxHu
+gq6VLzIi4ddcH5skfpKhqHd9ahXiWQDOXalRtKol7eL7Py208ij7NNfGjNEDbNV
OzodeDGtbywqRdgMLe4xtS3OGaQBAw8dVclcgg97h2eVkjjb61YoKex1fdCkPTsv
aSS+K4BSvfzueG+KG95Zac3az4dFtiloqMocCKN5D9FKeopDBp7JhZVwGr/BBoTx
xmU4wjI1lyxIgwPI2AcMxzawzauzGXivaavCopJ2O4NGFBfyMqHlNujRvYz1zbLh
faFePfWgOjAk8M9+ZZUpGiDHV1p9RWleAH7dmJV/qkQWBARA6WN9aM6N+wVdpVRb
aqnQVhYSAMfYNzLQw68/hJLWnnuqpli9ZHB0fCx4bdLxnsrAOP+IhLIHtq6lsO5Q
5ortpvL1334DAw24JXjGZQJoy0hNU+7VifLxMiNrwNbfTYU7tXPfUlJC1GYn2uNz
oTKXlSES1kJy4CxI1f3yCqq5UU+cW3H2Nz7VPfp/qa0tPCesArZYoe0e0FhZdypL
J9BPnne4nBX1aeB/oSC1r3x+SaVek556+qhbuFP4L0utD6PIY9PB00Ex2M0nqnco
YON/jqusioTsqOuYNOC+
=1xzD
-END PGP SIGNATURE-

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


Fughetta - a humble JFugue wrapper

2011-11-04 Thread Sebastian Rojas
I present to you Fughetta , my 
first usable Clojure project, it's very simple but i hope you like it.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Fughetta - a humble JFugue wrapper

2011-11-04 Thread Devin Walters
Gotta love jfugue. I've been toying with a wrapper as well. I'm guessing the 
folks in the overtone community would like to hear about this as well.

Sent via Mobile

On Nov 4, 2011, at 4:29 PM, Sebastian Rojas  wrote:

> I present to you Fughetta, my first usable Clojure project, it's very simple 
> but i hope you like it. 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this 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: Clojure Conj extracurricular activities spreadsheet

2011-11-04 Thread Michael Fogus
> Any thoughts about when / where these events can take place?

At this point it would be great if a Conj-planning heavyweight could
step in and provide some additional ideas... although solutions would
be great too.  :-)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure Conj extracurricular activities spreadsheet

2011-11-04 Thread Nick Brown
I'm interested in the core.logic and the web and clojure sessions.

On Oct 25, 12:11 pm, Fogus  wrote:
> All,
>
> We talked about the possibility of getting some ideas about
> extracurricular activities during the Conj days (and possibly training
> days).  I've created a spreadsheet at the link below to collect
> ideas.  It is not my intention to be the organizer of these
> activities.  Instead, if you have an idea then please be prepared to
> own it.  The matter of space for these activities would need to be
> worked out by Conj planners or activity organizers, but having a list
> would help that process.
>
> https://docs.google.com/spreadsheet/ccc?key=0Alim_jfrt24MdDFqZVZsNW0t...
>
> I've entered an example, feel free to add your own ideas. :-)
>
> This should be epic.

-- 
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: Simple Made Easy - Any Examples?

2011-11-04 Thread aboy021
For me personally the main areas that Rich cited that I've not found
good examples for are Rules, Set Functions, and Queues.
In particular moving the rules out sounds like a great idea.

I'll have a look at the projects that David suggested.

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


see if any branch of a cond succeeded

2011-11-04 Thread Martin DeMello
What's the cleanest way to run a piece of code if any branch of a cond
statement succeeded, without relying on the return value of the
individual clauses not to be nil?

For example, if I have the following piece of code that says I can
only move left or up

(cond
  (= dir :left) (move-left)
  (= dir :up)  (move-up))

but (move-left) or (move-up) could themselves return nil, is there any
nice way to check if one of them was called?

martin

-- 
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: see if any branch of a cond succeeded

2011-11-04 Thread Baishampayan Ghose
On Sat, Nov 5, 2011 at 11:55 AM, Martin DeMello  wrote:
> What's the cleanest way to run a piece of code if any branch of a cond
> statement succeeded, without relying on the return value of the
> individual clauses not to be nil?
>
> For example, if I have the following piece of code that says I can
> only move left or up
>
> (cond
>  (= dir :left) (move-left)
>  (= dir :up)  (move-up))
>
> but (move-left) or (move-up) could themselves return nil, is there any
> nice way to check if one of them was called?

What about something like this -

(cond
 (= dir :left) (move-left)
 (= dir :up)  (move-up)
 :else :nok)

Or

(cond
 (= dir :left) [(move-left)]
 (= dir :up)  [(move-up)])

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