ANN: monads 0.1.0, YA monads lib for clojure

2013-04-04 Thread Ben Wolfson
After much tinkering I am announcing a new monads implementation:

https://github.com/bwo/monads

Rather than using protocols or symbol macros as (I believe) all hitherto
existing monad libraries for Clojure have, this implementation has the
elements of a monadic computation build up a structure which the individual
monads interpret, with the goal of allowing for flexibility and
expressiveness.

The wiki has a small benchmark, which also gives an example of using the
state monad:
https://github.com/bwo/monads/wiki/Tree-numbering-benchmark

And an example of using monad transformer stacks, demonstrating the state,
writer, maybe, and error monads:
https://github.com/bwo/monads/wiki/An-expression-evaluator

Feedback welcome!

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: core.logic: Database context monad

2013-04-04 Thread JvJ
I'm actually very interested in getting involved with core.logic, but I'm 
having a hard time finding a comprehensive guide to the implementation of 
the systems.  I've gathered some bits and pieces about how goals work, but 
I'm not sure I totally understand the system.  Do you know any good places 
to start with that?

On Thursday, 4 April 2013 22:08:38 UTC-4, David Nolen wrote:
>
> Sounds interesting. I've seen nothing like this in the Prolog literature, 
> but I may not have looked hard enough. Probably worth investigating, might 
> turn up some other interesting ideas even if you can't make 
> assertion/retraction relational.
>
>
> On Thu, Apr 4, 2013 at 9:21 PM, JvJ >wrote:
>
>> I've been working a lot with core.logic and pldb (
>> https://github.com/threatgrid/pldb), and I've been troubled by the lack 
>> of an assertion operation that would allow addition of facts to a database 
>> as a relational operation.  I've been thinking that this could be solved by 
>> creating some kind of monad that could carry a database context along with 
>> variable substitutions when executing a logic program
>>
>> Is anybody working on anything like this, and does it seem like the kind 
>> of thing that may be useful/feasible to implement?
>>
>> Thanks.
>>
>> -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: no.disassemble, a runtime bytecode disassembler

2013-04-04 Thread Aaron
Cool...  I wrote a similar little disassembler for ClojureCLR a few weeks 
ago:

https://github.com/aaronc/ClojureClrEx/blob/master/src/clojure/clr/ildasm.clj

It uses Mono.Reflection to interpret the byte codes.

On Saturday, March 30, 2013 9:06:25 AM UTC-4, Gary Trakhman wrote:
>
> I made a little proof of concept last night.  You could always look at 
> bytecode that clojure emits in few ways, you can either hack the compiler 
> yourself, or force AOT in your project and use javap.  The first approach 
> is a bit intrusive, and the second has a somewhat annoying turnaround time, 
> and won't work for any code that calls eval at runtime.
>
> This takes another approach.  It uses java's Instrumentation stuff, to 
> provide a hook into all classloading past the point at which it's loaded, 
> where I store off all the bytes of defined classes into a big 
> ConcurrentHashMap.  Then I use eclipse.jdt.core's disassembler 
> functionality to print out the bytecode.
>
> There's a nice lein-plugin that adds the dependency to your project and 
> looks itself up in order to add the appropriate -javaagent flag to your jvm 
> startup options.
>
> Now you can do something like this:
>
> user=> (require 'no.disassemble)
> nil
>
> user=> (in-ns 'no.disassemble)
> #
>
> no.disassemble=> (println (disassemble (fn [])))
> // Compiled from NO_SOURCE_FILE (version 1.5 : 49.0, super bit)
> public final class no.disassemble$eval1174$fn__1175 extends 
> clojure.lang.AFunction {
>
>   // Method descriptor #7 ()V
>   // Stack: 0, Locals: 0
>   public static {};
> 0  return
>   Line numbers:
> [pc: 0, line: 1]
>
>   // Method descriptor #7 ()V
>   // Stack: 1, Locals: 1
>   public disassemble$eval1174$fn__1175();
> 0  aload_0
> 1  invokespecial clojure.lang.AFunction() [10]
> 4  return
>   Line numbers:
> [pc: 0, line: 1]
>
>   // Method descriptor #12 ()Ljava/lang/Object;
>   // Stack: 1, Locals: 1
>   public java.lang.Object invoke();
> 0  aconst_null
> 1  areturn
>   Line numbers:
> [pc: 0, line: 1]
>   Local variable table:
> [pc: 0, pc: 1] local: this index: 0 type: java.lang.Object
>
> }
> nil
> no.disassemble=> 
>
>
> Potential use cases:
>
> Writing fast code faster.
> Proving to newbies that clojure is not interpreted, further evidence of 
> eval's coolness.
> Checking to make sure primitives are being used where you expect.
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: core.logic: Database context monad

2013-04-04 Thread David Nolen
Sounds interesting. I've seen nothing like this in the Prolog literature,
but I may not have looked hard enough. Probably worth investigating, might
turn up some other interesting ideas even if you can't make
assertion/retraction relational.


On Thu, Apr 4, 2013 at 9:21 PM, JvJ  wrote:

> I've been working a lot with core.logic and pldb (
> https://github.com/threatgrid/pldb), and I've been troubled by the lack
> of an assertion operation that would allow addition of facts to a database
> as a relational operation.  I've been thinking that this could be solved by
> creating some kind of monad that could carry a database context along with
> variable substitutions when executing a logic program
>
> Is anybody working on anything like this, and does it seem like the kind
> of thing that may be useful/feasible to implement?
>
> Thanks.
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




core.logic: Database context monad

2013-04-04 Thread JvJ
I've been working a lot with core.logic and pldb (
https://github.com/threatgrid/pldb), and I've been troubled by the lack of 
an assertion operation that would allow addition of facts to a database as 
a relational operation.  I've been thinking that this could be solved by 
creating some kind of monad that could carry a database context along with 
variable substitutions when executing a logic program

Is anybody working on anything like this, and does it seem like the kind of 
thing that may be useful/feasible to implement?

Thanks.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: vim-redl -- advanced fuzzy omnicompletion and VimClojure-style repl with enhanced debugging features

2013-04-04 Thread dgrnbrg
You there are plug mappings for all the repl actions:

clj_repl_enter. -- key for enter press
clj_repl_eval. -- key to for evaluation in the middle of the repl 
(i.e. not at the end of the form)
clj_repl_hat. -- equivalent to ^
clj_repl_Ins. -- equivalent to I
clj_repl_uphist. -- history up
clj_repl_downhist. -- history down

You can look at the repl.vim file to see how to make new mappings. I create 
the default repl mappings only if you haven't provided custom ones.

On Thursday, April 4, 2013 12:40:38 PM UTC-4, Max Gonzih wrote:
>
> So I got it working and it's pretty cool. But is there any options to 
> remap default keys (for example I'm using "-_" instead of "$^")?
>
> Thanks
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Getting the right Clojure version with dependencies

2013-04-04 Thread Alexander Hudek
I strongly recommend lein-pedantic to help with problems like this. On 
large enough projects you can very easily get non-reproducible executions 
depending on how lein resolves conflicting dependencies. 

https://github.com/xeqi/lein-pedantic


On Thursday, April 4, 2013 7:32:04 PM UTC-4, puzzler wrote:
>
> Right now, I'm experimenting with seesaw.  In Clojars, it appears the 
> latest version is 1.4.2.
>
> When I include [seesaw "1.4.2"] in my project.clj file, then the REPL 
> comes up as 1.3.0 (even though I explicitly define clojure 1.5.1 as a 
> dependency in the project.clj file).  How do I make my preferred clojure 
> version take precedence over whatever seesaw is requesting?
>
> Thanks,
>
> Mark
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Getting the right Clojure version with dependencies

2013-04-04 Thread Mark Engelberg
Thanks everyone!

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Getting the right Clojure version with dependencies

2013-04-04 Thread Nelson Morris
The latest version of seesaw is 1.4.3.  Unfortunately there is a bug in
clojars with scp uploads that does not update the search index, so it is
showing an older version on the search page.

If you want seesaw 1.4.2 you can use  [seesaw "1.4.2" :exclusions
[org.clojure/clojure]].

If you are using lein 2.1.x you can use `lein deps :tree` and it should let
you know about any version ranges. They are usually the cause of dependency
issues like this.
On Apr 4, 2013 6:32 PM, "Mark Engelberg"  wrote:

> Right now, I'm experimenting with seesaw.  In Clojars, it appears the
> latest version is 1.4.2.
>
> When I include [seesaw "1.4.2"] in my project.clj file, then the REPL
> comes up as 1.3.0 (even though I explicitly define clojure 1.5.1 as a
> dependency in the project.clj file).  How do I make my preferred clojure
> version take precedence over whatever seesaw is requesting?
>
> Thanks,
>
> Mark
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Getting the right Clojure version with dependencies

2013-04-04 Thread Dave Ray
The latest Seesaw version on Clojars is 1.4.3. It addresses the Clojure
dependency issue.

Cheers,

Dave

On Thu, Apr 4, 2013 at 4:40 PM, Jim - FooBar(); wrote:

>  [ghostandthemachine/seesaw "1.4.3-SNAPSHOT" :exclusions [
> org.clojure/clojure]]
>
> Jim
>
> ps: maybe the actual coordinate for clojure  is wrong but I can
>
>
> On 05/04/13 00:32, Mark Engelberg wrote:
>
> Right now, I'm experimenting with seesaw.  In Clojars, it appears the
> latest version is 1.4.2.
>
> When I include [seesaw "1.4.2"] in my project.clj file, then the REPL
> comes up as 1.3.0 (even though I explicitly define clojure 1.5.1 as a
> dependency in the project.clj file).  How do I make my preferred clojure
> version take precedence over whatever seesaw is requesting?
>
> Thanks,
>
> Mark
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>  --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Getting the right Clojure version with dependencies

2013-04-04 Thread Jim - FooBar();

[ghostandthemachine/seesaw"1.4.3-SNAPSHOT":exclusions[org.clojure/clojure]]

Jim

ps: maybe the actual coordinate for clojure  is wrong but I can

On 05/04/13 00:32, Mark Engelberg wrote:
Right now, I'm experimenting with seesaw.  In Clojars, it appears the 
latest version is 1.4.2.


When I include [seesaw "1.4.2"] in my project.clj file, then the REPL 
comes up as 1.3.0 (even though I explicitly define clojure 1.5.1 as a 
dependency in the project.clj file).  How do I make my preferred 
clojure version take precedence over whatever seesaw is requesting?


Thanks,

Mark
--
--
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 unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--
--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Getting the right Clojure version with dependencies

2013-04-04 Thread Mark Engelberg
Right now, I'm experimenting with seesaw.  In Clojars, it appears the
latest version is 1.4.2.

When I include [seesaw "1.4.2"] in my project.clj file, then the REPL comes
up as 1.3.0 (even though I explicitly define clojure 1.5.1 as a dependency
in the project.clj file).  How do I make my preferred clojure version take
precedence over whatever seesaw is requesting?

Thanks,

Mark

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: vim-redl -- advanced fuzzy omnicompletion and VimClojure-style repl with enhanced debugging features

2013-04-04 Thread ronen
Very nice work, 

Thank you

On Wednesday, April 3, 2013 11:08:30 PM UTC+3, dgrnbrg wrote:
>
> Although I've announced vim-redl in the past, now you can reap the 
> benefits of all of its features without leaving fireplace behind! Just go 
> to https://github.com/dgrnbrg/vim-redl for installation instructions, and 
> you'll end up with advanced fuzzy omnicompletion and a full-fledged repl 
> (accessible via :ReplHere).
>
> Redl includes a Debug Repl, which allows you to freeze a REPL and inspect 
> local variables. See a sample session in action to understand better: 
> https://github.com/dgrnbrg/redl#debug-repl
>
> Pull requests and feature requests welcome!
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Some docs on comparators, including mistakes to avoid, & Clojure "extended doc strings"

2013-04-04 Thread Alan Shaw
Thumbs up on the comparators doc!
On Apr 4, 2013 12:49 PM, "Andy Fingerhut"  wrote:

> I am seriously considering the idea of working on some "extended doc
> strings" for Clojure functions.  Having only scratched the surface so far,
> I have learned that it could take a *lot* of hours to write such
> documentation for every function distributed as part of Clojure, at least
> if written in the way I've done so far for compare, sort, and for
> comparator functions.
>
> The document on comparator functions alone might be of interest to a few
> people.  You can read it here:
>
>
> https://github.com/jafingerhut/thalia/blob/master/doc/other-topics/comparators.md
>
> It has a few examples of good comparators, and mistakes to avoid when
> writing them that I have seen asked about here.  I take some inspiration
> from what I consider to be pretty good documentation for a programming
> language: Perl.  Type "man perlfunc" in a Linux or Mac OS X shell and
> you'll see what I mean.  Useful examples, corner cases, pitfalls, etc.  I
> like, use, and promote ClojureDocs.org, but I also like the idea of
> something a bit more curated.
>
> I don't have any code yet where you can type an expression in a REPL and
> get these docs back, but that wouldn't be hard to do.  It wouldn't be very
> useful to implement that until there are a lot more extended doc strings
> written.  I'll announce more later if that happens.  I know Rich Morin
> expressed some interest in a project like this in an earlier thread [1],
> but if anyone is interested, feel free to contact me privately and we can
> talk.
>
> [1]
> https://mail.google.com/mail/?shva=1#search/label%3Aclojure+rich+morin/13c5fab22e24cd23
>
> I do have a skeleton of a directory tree with regular predictable names
> for Markdown-format files for every public symbol in Clojure 1.5.1 (not all
> checked in to that Github repo yet), using Lee Hinman's lein-clojuredocs to
> extract that info from it and all other Clojure contrib libraries.
>
>
> Side note: At the end my comparators document has the beginnings of a
> "compare any pair of values" comparator mentioned by Mark Engelberg as a
> wish list item in a message from last November [2].  That version, called
> cc-cmp, still doesn't work for Clojure sets and maps, but it wouldn't be
> difficult to extend it to those by sorting the elements/keys and then
> comparing them as sequences.  I suspect it would be best to write a version
> using multimethods or protocols that could be easily extended by others to
> additional types, without needing to modify the original code.
>
> [2]
> https://mail.google.com/mail/?shva=1#search/engelberg+compare/13b1e8a3f7f9a59d
>
> Andy
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: -> operator and monads

2013-04-04 Thread Marko Topolnik
Isn't the dot just like Clojure's *comp*? As Allan correctly points out, 
the thrushes are macros that combine the given forms in a specified way, 
which only under certain constraints has the effect of composing function 
applications, whereas *comp* is truly a function composition operator.

On Thursday, April 4, 2013 4:25:18 PM UTC+2, Maik Schünemann wrote:
>
> if you come from the haskell world, it is like . piplining - but in 
> reverse order
> I needed some time to get used to it but I really like -> ->> as-> ... to 
> structure my code. 
> It helps to see the sequence of functions that operate on your data
>
>
> On Wed, Apr 3, 2013 at 11:05 PM, Alan Malloy 
> > wrote:
>
>> Not even that: -> is not a function composition operator at all, but a 
>> form-rewriting macro. You can perfectly well write (-> [x xs] (for (inc 
>> x))) to get (for [x xs] (inc x)), and that is not composing any functions. 
>> The two things are entirely separate.
>>
>>
>> On Wednesday, April 3, 2013 12:45:55 PM UTC-7, Marko Topolnik wrote:
>>>
>>> I guess you mean the monadic bind operation, but -> is not it. The only 
>>> conceptual connection between *bind* and -> is that they are both some 
>>> kind of function composition operators.
>>>
>>> -marko
>>>
>>> On Wednesday, April 3, 2013 8:21:43 PM UTC+2, Plinio Balduino wrote:

 Hi there

 Is it correct to say that -> operator is a kind of monad in Clojure?

 Thank you in advance.

 Plínio Balduino
  
>>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Some docs on comparators, including mistakes to avoid, & Clojure "extended doc strings"

2013-04-04 Thread Andy Fingerhut
I am seriously considering the idea of working on some "extended doc
strings" for Clojure functions.  Having only scratched the surface so far,
I have learned that it could take a *lot* of hours to write such
documentation for every function distributed as part of Clojure, at least
if written in the way I've done so far for compare, sort, and for
comparator functions.

The document on comparator functions alone might be of interest to a few
people.  You can read it here:


https://github.com/jafingerhut/thalia/blob/master/doc/other-topics/comparators.md

It has a few examples of good comparators, and mistakes to avoid when
writing them that I have seen asked about here.  I take some inspiration
from what I consider to be pretty good documentation for a programming
language: Perl.  Type "man perlfunc" in a Linux or Mac OS X shell and
you'll see what I mean.  Useful examples, corner cases, pitfalls, etc.  I
like, use, and promote ClojureDocs.org, but I also like the idea of
something a bit more curated.

I don't have any code yet where you can type an expression in a REPL and
get these docs back, but that wouldn't be hard to do.  It wouldn't be very
useful to implement that until there are a lot more extended doc strings
written.  I'll announce more later if that happens.  I know Rich Morin
expressed some interest in a project like this in an earlier thread [1],
but if anyone is interested, feel free to contact me privately and we can
talk.

[1]
https://mail.google.com/mail/?shva=1#search/label%3Aclojure+rich+morin/13c5fab22e24cd23

I do have a skeleton of a directory tree with regular predictable names for
Markdown-format files for every public symbol in Clojure 1.5.1 (not all
checked in to that Github repo yet), using Lee Hinman's lein-clojuredocs to
extract that info from it and all other Clojure contrib libraries.


Side note: At the end my comparators document has the beginnings of a
"compare any pair of values" comparator mentioned by Mark Engelberg as a
wish list item in a message from last November [2].  That version, called
cc-cmp, still doesn't work for Clojure sets and maps, but it wouldn't be
difficult to extend it to those by sorting the elements/keys and then
comparing them as sequences.  I suspect it would be best to write a version
using multimethods or protocols that could be easily extended by others to
additional types, without needing to modify the original code.

[2]
https://mail.google.com/mail/?shva=1#search/engelberg+compare/13b1e8a3f7f9a59d

Andy

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread Ben Wolfson
On Thu, Apr 4, 2013 at 8:44 AM, Tassilo Horn  wrote:

>
> However, the what's bad with the juxt approach above is that the
> collection is iterated twice.  If somebody comes up with a version that
> returns a vector of two lazy seqs and which iterates the input
> collection only once, she'd get my warmest thank you, and my vote for
> putting it into core.
>
>
here's a first shot, kind of ugly but seems to work:

user> (defn seqmr
  [f g a bs]
  (lazy-seq
   (if (seq bs)
 (g (f (first bs)) (seqmr f g a (rest bs)))
 a)))
#'user/seqmr
user> (defn lazy-partition [p xs]
  (seqmr (fn [x]
   [(p x) x])
 (fn [[t? x] r]
   (if t?
 [(lazy-seq (cons x (first r))) (lazy-seq (second r))]
 [(lazy-seq (first r)) (lazy-seq (cons x (second r)))]))
 [() ()]
 xs))
#'user/lazy-partition
user> (def r (lazy-partition even? (map #(do (print % "") %) (range 129
#'user/r
user> (first (first r))
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
28 29 30 31
0
user> (first (second r))
1
user> (nth (second r) 10)
21
user> (nth (second r) 20)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
57 58 59 60 61 62 63
41
user> (nth (first r) 20)
40


-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread Jim - FooBar();
Yes it is indeed cool but it suffers from the same problem as the juxt 
version (as Tassillo mentioned)...they are both very elegant and 
succinct but unfortunately slow for large sequences. The group-by 
version and the doseq version are way faster...also, there is a 
reducer-based filter if you want go parallel...


you asked where to find this funciton... a couple of places actually :)
http://clojuredocs.org/clojure_contrib/clojure.contrib.seq-utils/separate
http://richhickey.github.com/clojure-contrib/seq-utils-api.html

HTH,

Jim



On 04/04/13 19:12, Christian Romney wrote:

On Thursday, April 4, 2013 12:13:13 PM UTC-4, Jim foo.bar wrote:

there is a separate fn in contrib and does exactly what you want
(assuming you don't care about the 2 passes):

(defn separate
"Returns a vector:
[ (filter f s), (filter (complement f) s) ]"
[f s]
[(filter f s) (filter (complement f) s)])


Very cool—where can I find this? I ask because there may be other 
goodies I should be aware of...
I also like Tassilo's version using juxt. It's great to see the same 
problem solved different ways.


--
--
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 unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--
--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread Christian Romney
On Thursday, April 4, 2013 12:13:13 PM UTC-4, Jim foo.bar wrote:

>  there is a separate fn in contrib and does exactly what you want 
> (assuming you don't care about the 2 passes):
>
> (defn separate
>   "Returns a vector:
>[ (filter f s), (filter (complement f) s) ]"
>   [f s]
>   [(filter f s) (filter (complement f) s)])
>
>
Very cool—where can I find this? I ask because there may be other goodies I 
should be aware of... 
I also like Tassilo's version using juxt. It's great to see the same 
problem solved different ways.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: vim-redl -- advanced fuzzy omnicompletion and VimClojure-style repl with enhanced debugging features

2013-04-04 Thread Max Gonzih
So I got it working and it's pretty cool. But is there any options to remap 
default keys (for example I'm using "-_" instead of "$^")?

Thanks

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread Jim - FooBar();
there is a separate fn in contrib and does exactly what you want 
(assuming you don't care about the 2 passes):


(defn separate
"Returns a vector:
[ (filter f s), (filter (complement f) s) ]"
[f s]
[(filter f s) (filter (complement f) s)])



If you do care about the 2 passes you can always fall back to imperative 
code + transients like so:


(defn separate [pred coll] ;;should be really fast as it only does a 
single pass

  (let [[yes no :as both]  (list (transient []) (transient []))]
(doseq [x coll]
 (if (pred x) (conj! yes x)
  (conj! no x)))
  (mapv persistent! both)))

Jim


On 04/04/13 13:16, Christian Romney wrote:

Hi all,

I was wondering if something in core (or new contrib) like this exists 
already...


(defn segregate
"Takes a predicate, p, and a collection, coll, and separates the items 
in coll

into matching and non-matching subsets. Like Scheme or Ruby's partition."
[p coll]
(loop [s coll y [] n []]
(if (empty? s) [y n]
(if (p (first s))
(recur (rest s) (conj y (first s)) n)
(recur (rest s) y (conj n (first s)))
(let [[odds evens] (segregate odd? (range 1 11))]
(println evens))
In Scheme (and Ruby) this function is partition, which is quite 
different from /partition(-all|-by)?/ in Clojure:

#lang racket
(let-values [[(odds evens) (partition odd? (range 1 11))]]
(display evens))
If not, I have two follow-up questions.
1) Is there a better way to write segregate
2) Is this useful enough to consider adding to core?
TIA, and my apologies for the newbie question. :)
(Gist version if you prefer: https://gist.github.com/xmlblog/5309853)
--
--
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 unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--
--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread Tassilo Horn
Christian Romney  writes:

Hey Christian,

> (defn segregate 
>   "Takes a predicate, p, and a collection, coll, and separates the items in 
> coll 
>into matching and non-matching subsets. Like Scheme or Ruby's partition."
>   [p coll]
>   (loop [s coll y [] n []]
> (if (empty? s) [y n]
>   (if (p (first s)) 
> (recur (rest s) (conj y (first s)) n)
> (recur (rest s) y (conj n (first s)))
>
> If not, I have two follow-up questions.

No, I think there's nothing like that in core.  But I also feel a need
for that, since I also frequently do

  (let [e (filter even? coll)
o (remove even? coll)]
...)

which is nearly equivalent, except that it's lazy (i.e., e and o are
lazy seqs) where yours is eager (returns two vectors).  group-by in core
is also eager.

> 1) Is there a better way to write segregate

This would work and also returns a vector of two lazy seqs:

  (def segregate (juxt filter remove))

Then you can do

  (let [[e o] (segregate even? coll)]
...)

exactly as with your version.

> 2) Is this useful enough to consider adding to core?

IMHO, yes, but it should return a vector of 2 lazy seqs.  The eager case
is captured enough by group-by, IMHO.

However, the what's bad with the juxt approach above is that the
collection is iterated twice.  If somebody comes up with a version that
returns a vector of two lazy seqs and which iterates the input
collection only once, she'd get my warmest thank you, and my vote for
putting it into core.

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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to use clojure.core.logic to generate strings?

2013-04-04 Thread David Nolen
There is currently no simple way to make a substring goal beyond
manipulating strings as sequences which is not ideal. The constraint
framework does make it possible, but that API is under change so you can't
build things upon it reliably yet.

So project is your best option for now.


On Thu, Apr 4, 2013 at 10:39 AM, Adam Saleh  wrote:

> Thanks, this got me quite far.
>
> But I'd like to create goals with string, for example currently I have no
> idea, how would I write a substring goal.
>
> Thanks for any suggestion!
>
> Adam
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to use clojure.core.logic to generate strings?

2013-04-04 Thread Adam Saleh
Thanks, this got me quite far.

But I'd like to create goals with string, for example currently I have no 
idea, how would I write a substring goal.

Thanks for any suggestion!

Adam

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: -> operator and monads

2013-04-04 Thread Maik Schünemann
if you come from the haskell world, it is like . piplining - but in reverse
order
I needed some time to get used to it but I really like -> ->> as-> ... to
structure my code.
It helps to see the sequence of functions that operate on your data


On Wed, Apr 3, 2013 at 11:05 PM, Alan Malloy  wrote:

> Not even that: -> is not a function composition operator at all, but a
> form-rewriting macro. You can perfectly well write (-> [x xs] (for (inc
> x))) to get (for [x xs] (inc x)), and that is not composing any functions.
> The two things are entirely separate.
>
>
> On Wednesday, April 3, 2013 12:45:55 PM UTC-7, Marko Topolnik wrote:
>>
>> I guess you mean the monadic bind operation, but -> is not it. The only
>> conceptual connection between *bind* and -> is that they are both some
>> kind of function composition operators.
>>
>> -marko
>>
>> On Wednesday, April 3, 2013 8:21:43 PM UTC+2, Plinio Balduino wrote:
>>>
>>> Hi there
>>>
>>> Is it correct to say that -> operator is a kind of monad in Clojure?
>>>
>>> Thank you in advance.
>>>
>>> Plínio Balduino
>>>
>>  --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread John D. Hume
On Thu, Apr 4, 2013 at 8:06 AM, David Powell  wrote:
> You could use the long-form of map destructuring:
>
> (let [{odd true even false} (group-by odd? (range 1 10))]
>   (println odd)
>   (println even))

I do this frequently. Do be careful that if your "predicate" doesn't
return actual booleans, you may want to coerce with (boolean ...).

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to use clojure.core.logic to generate strings?

2013-04-04 Thread David Nolen
str is a function not a goal/relation - it doesn't know how to deal with
logic vars. If you want that to work you will need to project result first.
But if you project result then order matters and the unification of query
must come after the membero call.


On Thu, Apr 4, 2013 at 9:25 AM, Adam Saleh  wrote:

> Hi, I am trying to write myself something to generate some test data, and
> I thought
> clojure.core logic fits the bill ... unfortunately, for some reason, it
> doesn't work.
>
> In my project.clj:
>
> [org.clojure/clojure "1.5.0"]
> [org.clojure/core.logic "0.8.3"]
>
> in my namespace:
> (ns tests.search
>   (:require
>  [clojure.set :refer [intersection difference union project select]]
>  [clojure.core.logic :as l]))
>
>  (def search-table
>((fn [header table] (into #{} (map #(zipmap header %1) table)))
>
>[:title :type :severity]
>   [[ "Squirrel" "enhancement" "low"]
>[ "Camel""security""important"]
>[ "Dog"  "security""critical"]
>[ "Cow"  "bugfix"  "moderate"]]))
>
>
> Now, I try to generate pairs [query result] with logic programming.
>
> (l/run 1  [test-line]
>  (l/fresh [query result]
>(l/== query ["\"" result "\""])
>(l/membero result (map :name (project errata-search-table [:name])))
>(l/== test-line [query result])))
>
> >> ([["\"" "Squirrell" "\""] "Squirrell"])
>
> But I can't figure out how to force query to unify to a string:
>
> (l/run 1  [test-line]
>  (l/fresh [query result]
>(l/== query (str "\"" result "\""))
>(l/membero result (map :name (project errata-search-table [:name])))
>(l/== test-line [query result])))
>
> >> (["\"\"" "Squirrell"])
>
> When I asked on freenode, I got this response:
>
>  asaleh: str is impure, using e.g. (fresh [x y] (== y (str x)))
> won't work
>
> Thanks,
>
> Adam
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




How to use clojure.core.logic to generate strings?

2013-04-04 Thread Adam Saleh
Hi, I am trying to write myself something to generate some test data, and I 
thought 
clojure.core logic fits the bill ... unfortunately, for some reason, it 
doesn't work.

In my project.clj:

[org.clojure/clojure "1.5.0"]
[org.clojure/core.logic "0.8.3"]

in my namespace:
(ns tests.search
  (:require
 [clojure.set :refer [intersection difference union project select]]
 [clojure.core.logic :as l]))

 (def search-table
   ((fn [header table] (into #{} (map #(zipmap header %1) table)))
   
   [:title :type :severity]
  [[ "Squirrel" "enhancement" "low"]
   [ "Camel""security""important"]
   [ "Dog"  "security""critical"]
   [ "Cow"  "bugfix"  "moderate"]]))


Now, I try to generate pairs [query result] with logic programming.

(l/run 1  [test-line]
 (l/fresh [query result]
   (l/== query ["\"" result "\""])
   (l/membero result (map :name (project errata-search-table [:name])))
   (l/== test-line [query result])))

>> ([["\"" "Squirrell" "\""] "Squirrell"])

But I can't figure out how to force query to unify to a string:

(l/run 1  [test-line]
 (l/fresh [query result]
   (l/== query (str "\"" result "\""))
   (l/membero result (map :name (project errata-search-table [:name])))
   (l/== test-line [query result])))

>> (["\"\"" "Squirrell"])

When I asked on freenode, I got this response:

 asaleh: str is impure, using e.g. (fresh [x y] (== y (str x))) 
won't work

Thanks,

Adam

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread David Powell
> I thought about map destructuring but I don't think it works with boolean
> keys. I think this is good enough though:
>

You could use the long-form of map destructuring:

(let [{odd true even false} (group-by odd? (range 1 10))]
  (println odd)
  (println even))

-- 
Dave

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread Christian Romney
On Thursday, April 4, 2013 8:25:32 AM UTC-4, Jonathan Fischer Friberg wrote:

> I think group-by can do what you want (and more);
>

Hi Jonathan,

Thanks for the reply. I had looked at group-by, and hastily dismissed it 
due to lack of imagination. This would work, though it isn't as "pretty".

(let [is-odd (group-by odd? (range 1 11))]
  (println (is-odd false)))


I thought about map destructuring but I don't think it works with boolean 
keys. I think this is good enough though:

(let [is-odd (group-by odd? (range 1 11))
  evens (is-odd false)
  odds (is-odd true)]
  (println evens))

Thanks again

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: vim-redl -- advanced fuzzy omnicompletion and VimClojure-style repl with enhanced debugging features

2013-04-04 Thread David Greenberg

   
   - :injections [(require '[redl core complete])] 
   - :dependencies [[redl "0.1.0"]]

Did you see those 2 lines in the installation instructions in the readme? 
You need to include them both in your profiles.clj. I've updated the readme 
to now also include a sample profiles.clj.

Thanks!

On Thursday, April 4, 2013 4:17:25 AM UTC-4, Max Gonzih wrote:
>
> Awesome! Thank you!
>
> Can you add example profiles.clj to readme? Because I can understand how 
> to configure Clojure component.
>
> On Wednesday, April 3, 2013 11:08:30 PM UTC+3, David Greenberg wrote:
>>
>> Although I've announced vim-redl in the past, now you can reap the 
>> benefits of all of its features without leaving fireplace behind! Just go 
>> to https://github.com/dgrnbrg/vim-redl for installation instructions, 
>> and you'll end up with advanced fuzzy omnicompletion and a full-fledged 
>> repl (accessible via :ReplHere).
>>
>> Redl includes a Debug Repl, which allows you to freeze a REPL and inspect 
>> local variables. See a sample session in action to understand better: 
>> https://github.com/dgrnbrg/redl#debug-repl
>>
>> Pull requests and feature requests welcome!
>>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: nested reduce/reduce-kv idiom

2013-04-04 Thread John D. Hume
On Apr 4, 2013 6:54 AM, "Jim - FooBar();"  wrote:
>
> Thanks John,
>
> I came up with this, which uses destructuring quite heavily and might
slow things down...
>
> (reduce (fn [s [t1 t2 w3 v]] (assoc-in s [t1 t2 w3] (/ (count v) all))) {}
> (for [[k1 v1] ems [k2 v2] v1 [k3 v3] v2] [k1 k2 k3 v3]))
>
> is this what you meant?

Yes, something like that.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread Jonathan Fischer Friberg
I think group-by can do what you want (and more);

http://clojuredocs.org/clojure_core/clojure.core/group-by

Jonathan


On Thu, Apr 4, 2013 at 2:16 PM, Christian Romney  wrote:

> Hi all,
>
> I was wondering if something in core (or new contrib) like this exists
> already...
>
> (defn segregate
>   "Takes a predicate, p, and a collection, coll, and separates the items in 
> coll
>into matching and non-matching subsets. Like Scheme or Ruby's partition."
>   [p coll]
>   (loop [s coll y [] n []]
> (if (empty? s) [y n]
>   (if (p (first s))
> (recur (rest s) (conj y (first s)) n)
> (recur (rest s) y (conj n (first s)))
>
>
> (let [[odds evens] (segregate odd? (range 1 11))]
>   (println evens))
>
> In Scheme (and Ruby) this function is partition, which is quite different 
> from /partition(-all|-by)?/ in Clojure:
>
> #lang racket
>
> (let-values [[(odds evens) (partition odd? (range 1 11))]]
>   (display evens))
>
> If not, I have two follow-up questions.
>
> 1) Is there a better way to write segregate
> 2) Is this useful enough to consider adding to core?
>
> TIA, and my apologies for the newbie question. :)
>
> (Gist version if you prefer: https://gist.github.com/xmlblog/5309853)
>
>  --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Analog to Scheme's partition in Clojure?

2013-04-04 Thread Christian Romney
Hi all,

I was wondering if something in core (or new contrib) like this exists 
already...

(defn segregate 
  "Takes a predicate, p, and a collection, coll, and separates the items in 
coll 
   into matching and non-matching subsets. Like Scheme or Ruby's partition."
  [p coll]
  (loop [s coll y [] n []]
(if (empty? s) [y n]
  (if (p (first s)) 
(recur (rest s) (conj y (first s)) n)
(recur (rest s) y (conj n (first s)))
 
 
(let [[odds evens] (segregate odd? (range 1 11))]
  (println evens))

In Scheme (and Ruby) this function is partition, which is quite different from 
/partition(-all|-by)?/ in Clojure:

#lang racket
 
(let-values [[(odds evens) (partition odd? (range 1 11))]]
  (display evens))

If not, I have two follow-up questions.

1) Is there a better way to write segregate
2) Is this useful enough to consider adding to core?

TIA, and my apologies for the newbie question. :)

(Gist version if you prefer: https://gist.github.com/xmlblog/5309853)

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: nested reduce/reduce-kv idiom

2013-04-04 Thread Jim - FooBar();

Thanks John,

I came up with this, which uses destructuring quite heavily and might 
slow things down...


(reduce (fn [s [t1 t2 w3 v]] (assoc-in s [t1 t2 w3] (/ (count v) all))) {}
(for [[k1 v1] ems [k2 v2] v1 [k3 v3] v2] [k1 k2 k3 v3]))

is this what you meant?

Jim


On 03/04/13 19:54, John D. Hume wrote:

Destructure the map entry.
(for [[k vs] some-map, v vs] v) or whatever.

On Wed, Apr 3, 2013 at 1:44 PM, Jim - FooBar();  wrote:

Hi all,

I 've recently come across this idiom (instead of nested reduces - from
Christophe's blog post of course!)

(reduce f init (for [x xs, y x, z y] z)) ;;it took me a while to realise how
cool this is :)


I'm trying to do the same for reduce-kv (for nested maps) but doesn't quite
work...has anyone done this already? It comes down to 'seq' returning a
[k,v] vector when called on a map so the second nesting level will break
because it will find a keyword or something similar. any ideas?


Jim


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







--
--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: vim-redl -- advanced fuzzy omnicompletion and VimClojure-style repl with enhanced debugging features

2013-04-04 Thread Max Gonzih
Awesome! Thank you!

Can you add example profiles.clj to readme? Because I can understand how to 
configure Clojure component.

On Wednesday, April 3, 2013 11:08:30 PM UTC+3, David Greenberg wrote:
>
> Although I've announced vim-redl in the past, now you can reap the 
> benefits of all of its features without leaving fireplace behind! Just go 
> to https://github.com/dgrnbrg/vim-redl for installation instructions, and 
> you'll end up with advanced fuzzy omnicompletion and a full-fledged repl 
> (accessible via :ReplHere).
>
> Redl includes a Debug Repl, which allows you to freeze a REPL and inspect 
> local variables. See a sample session in action to understand better: 
> https://github.com/dgrnbrg/redl#debug-repl
>
> Pull requests and feature requests welcome!
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.