Wrong documentation of contains?

2013-08-07 Thread Goldritter
In an program I used the result of keys as an argument for a function which 
verifies whether an object is in a passed collection or not.
The result I got was following Exception:
IllegalArgumentException contains? not supported on type: 
clojure.lang.APersistentMap$KeySeq  clojure.lang.RT.contains (RT.java:724)

What are the reasons behind this Exception?

In the documentation of contains? it is written, that 
"Returns true if key is present in the given collection, otherwise returns 
false."
The examples on this page 
(http://clojuredocs.org/clojure_core/clojure.core/contains_q) and the 
parameter description indicates, that contains? accept any collection as 
argument.

The result of keys is also a collection
=> (coll? (keys {:a "f" :b 23}))
true

So is this a bug or is there a reason behind the fact, that contains? does 
not accept any collection?
Or is the documentation wrong and it should nor be a collection as argument 
but a set or a vector?

Because I get the same Exception for a list, but not for a vector.
The same for lists, which returns also true for coll?.
=> (coll? '(1 2 3 4))
true

=> (contains? '(1 2 3 4) 3)
IllegalArgumentException contains? not supported on type: 
clojure.lang.PersistentList  clojure.lang.RT.contains (RT.java:724) 

=> (contains? [1 2 3 4] 3)
true

-- 
-- 
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: Wrong documentation of contains?

2013-08-07 Thread Baishampayan Ghose
Hi,

`contains?` only works with associative data-structures like maps &
vectors. If you want to find out if a sequence contains a specific
object then you need to use `some` paired with a set as a predicate.

For example:

(some #{3} '(1 2 3 4))

Hope this helps.

~BG


On Wed, Aug 7, 2013 at 4:54 PM, Goldritter
 wrote:
> In an program I used the result of keys as an argument for a function which
> verifies whether an object is in a passed collection or not.
> The result I got was following Exception:
> IllegalArgumentException contains? not supported on type:
> clojure.lang.APersistentMap$KeySeq  clojure.lang.RT.contains (RT.java:724)
>
> What are the reasons behind this Exception?
>
> In the documentation of contains? it is written, that
> "Returns true if key is present in the given collection, otherwise returns
> false."
> The examples on this page
> (http://clojuredocs.org/clojure_core/clojure.core/contains_q) and the
> parameter description indicates, that contains? accept any collection as
> argument.
>
> The result of keys is also a collection
> => (coll? (keys {:a "f" :b 23}))
> true
>
> So is this a bug or is there a reason behind the fact, that contains? does
> not accept any collection?
> Or is the documentation wrong and it should nor be a collection as argument
> but a set or a vector?
>
> Because I get the same Exception for a list, but not for a vector.
> The same for lists, which returns also true for coll?.
> => (coll? '(1 2 3 4))
> true
>
> => (contains? '(1 2 3 4) 3)
> IllegalArgumentException contains? not supported on type:
> clojure.lang.PersistentList  clojure.lang.RT.contains (RT.java:724)
>
> => (contains? [1 2 3 4] 3)
> true
>
> --
> --
> 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.
>
>



-- 
Baishampayan Ghose
b.ghose at gmail.com

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




[proposal] simplified but extensible ns declaration

2013-08-07 Thread Phillip Lord


At the risk of continuing an already long thread on the namespace declaration,
I want to present my proposal for changing the namespace declaration. Unlike
Greg's proposal, it is not about changing the syntax, but fundamentally
changes the nature of the declaration.

One of the  things about the current namespace declaration is that it
is very complex, but has a lot of functionality. We can require, refer and
use. We can take a complete list and specify subsets (clojure.core :exclude
[partition]) We can specify standard prefixes (clojure.core match logic). We
can specify aliases (clojure.core.match :as m). And we can do lots of similar
stuff with imports for Java classes also. Hence, the namespace macro has got 
very complex.

The irony of this is that a lot of the complexity is effectively to enable the
manipulation of lists in a declarative way; surely this is something that we
could just use clojure to do.

So, the idea is that the ns form would change to take only two directives.
:require and :import (I'm ignoring things like :gen-class which would remain
untouched). Currently these things take lists. My proposal is, instead, that
they take closures that evaluate to a list. These lists could have a
relatively simple structure. So for require an item like 

  clojure.core/partition  would mean "require clojure.core/partition"
  [clojure.core/partition :as c/parition] 
 would mean "require clojure.core/partition but 
  call it c/partition"
  [clojure.core/partition :use] 
  would mean "require clojure.core/partition, but 
  call it partition"

Of course, producing these lists would be painful manually, but now that ns
macro takes closures, we can automate these things. To do this, we create a
new namespace (clojure.core.namespace) with useful functions (or macros
anyway, so we can use symbols). So

(all clojure.core)

would expand to something like

(vals (ns-publics 'clojure.core))

while

(only clojure.core map filter conj) 

would expand to something like

(for [k [map filter conj]]
 (symbol (concat "clojure.core" (name k

If we want "use" functionality we do define 

(use nnn)

expanding to

(for [k nnn]
   [k :use])

so

(use (all clojure.core))

would do the equivalent of (:use [clojure.core])

Now, if you want to do wildcard, or regular expression support, it can be
added *without* changing the ns macro. The same can be done for the import
declaration. 

This allows us to do imaginative things. What about loading import statements
from a file? Why would this be useful? Well, we have discussed wildcard import
statements before. but it noted that it requires crawling paths. We could do
something like

   (:import (from-dep [net.sourceforge.owlapi/owlapi-api] 
 OWLObject OWLRestriction))

What this would mean is "from the dependency owlapi-api import OWLObject and
OWLRestriction whatever their packages are". In terms of implementation,
"from" would read a header file which enumerates all the classes in the
dependency given -- the file name would be a transformation of the dependency.
This file would be generated by leiningen only when necessary (after a
dependency was introduced or updated), and outside of the actually clojure
process. The "from-dep" macro would need no knowledge of maven dependencies,
only how to syntactically transform the dependency to a file name.

Now, I can see a significant bootstrap problem -- functions that we want to
use in the namespace macro might not have been required yet. Ideally, I think,
we would want clojure.core and clojure.core.namespace to be automatically used
within the ns declaration. So, I don't quite know how this would be
implemented. Also from a tool creator point of view, the namespace declaration
becomes unparsable because it's extensible -- this would be eased by having a
an "expand-ns" macro which evaluates the ns macro using the same logic into a
normalised long hand form. Tool creaters could use clojure to interogate the ns
declaration. 

But the key point here is that we now have a fully extensible namespace
declaration where we are using clojure to manipulate the lists that we need.
The namespace form itself becomes relatively simple. And any complexity that
we need can be provided by additional functions, each of which can provide
better documentation than we currently have.

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

Re: Wrong documentation of contains?

2013-08-07 Thread Marcus Lindner
Thanks.

But the problem is, that this is not mentioned in the documentation of
contains? I found so far :(.
I had such a problem a long time ago and remember now which type of
"collection" can be used with contains?. But after a time I will forget
this again and will refer to the documentation. (And when I get the
Exception I remember again.)

And I think this question arise also more frequently.

But then my assumption that the documentation of contains? is misleading is
true. Is it possible to update the documentation for the next version?






2013/8/7 Baishampayan Ghose 

> Hi,
>
> `contains?` only works with associative data-structures like maps &
> vectors. If you want to find out if a sequence contains a specific
> object then you need to use `some` paired with a set as a predicate.
>
> For example:
>
> (some #{3} '(1 2 3 4))
>
> Hope this helps.
>
> ~BG
>
>
> On Wed, Aug 7, 2013 at 4:54 PM, Goldritter
>  wrote:
> > In an program I used the result of keys as an argument for a function
> which
> > verifies whether an object is in a passed collection or not.
> > The result I got was following Exception:
> > IllegalArgumentException contains? not supported on type:
> > clojure.lang.APersistentMap$KeySeq  clojure.lang.RT.contains
> (RT.java:724)
> >
> > What are the reasons behind this Exception?
> >
> > In the documentation of contains? it is written, that
> > "Returns true if key is present in the given collection, otherwise
> returns
> > false."
> > The examples on this page
> > (http://clojuredocs.org/clojure_core/clojure.core/contains_q) and the
> > parameter description indicates, that contains? accept any collection as
> > argument.
> >
> > The result of keys is also a collection
> > => (coll? (keys {:a "f" :b 23}))
> > true
> >
> > So is this a bug or is there a reason behind the fact, that contains?
> does
> > not accept any collection?
> > Or is the documentation wrong and it should nor be a collection as
> argument
> > but a set or a vector?
> >
> > Because I get the same Exception for a list, but not for a vector.
> > The same for lists, which returns also true for coll?.
> > => (coll? '(1 2 3 4))
> > true
> >
> > => (contains? '(1 2 3 4) 3)
> > IllegalArgumentException contains? not supported on type:
> > clojure.lang.PersistentList  clojure.lang.RT.contains (RT.java:724)
> >
> > => (contains? [1 2 3 4] 3)
> > true
> >
> > --
> > --
> > 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.
> >
> >
>
>
>
> --
> Baishampayan Ghose
> b.ghose at gmail.com
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To 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: PoC: Combining Wikidata and Clojure logic programming

2013-08-07 Thread Karsten Schmidt
Hi Mingli,

FYI for the past 3 months I've been working almost fulltime on a
lightweight, modular RDF Clojure toolkit, which I plan to opensource in the
near future, once the core API has more solidified. The kit so far features:

* core RDF datatype protocols (URIs, blank nodes, literals, containers &
XSD type handling via multimethods)
* simple & named graphs, datasets of multiple graphs
* protocol based triple store implementations: in-memory (Clojure data
structures), Redis, Cassandra (WIP)
* SPARQL style query & update engine:
  ** queries currently expressed as Clojure expressions
  ** SPARQL syntax parser (WIP)
  ** customizable query optimizations
  ** fixed-length property paths
  ** basic federation queries
  ** optional queries
  ** filter expressions, binding injection, grouping, sorting
* graph -> tree mapper to turn a set of triples into nested object maps
* rule based inferencing
  ** supplied rule set of common OWL/RDFS semantics
* streaming Turtle & JSON-LD IO, SPARQL result export as CSV, XML & JSON
* customizable CSV -> RDF conversion

Current focus of development:
* SPARQL HTTP endpoint & protocol implementation
* Streamed reasoning/inferencing w/ SPARQL-T
* Extend support of OWL semantics in query engine
* SPIN support, allowing queries, constraints & inference rules to be
defined in RDF
* async distributed query processor
* Library of AngularJS visualization directives/components of SPARQL
results (written in CLJS)

In terms of performance, I can't unfortunately share yet any real benchmark
results since I've only recently started looking into that for some core
components, but IMHO things are looking promising (and obviously still have
lengths to go). E.g. Using the in-memory store, the standard LUBM dataset
with 1 uni & 105k triples loads in avg. 4.8 secs on a 2010 MBP. With the
Redis store (using the fabulous Carmine lib), the same loads in under 11
secs, but I know this will be a lot faster once I've switched to batching.
So far the query engine has only been tested with smaller datasets (around
20k triples) and medium complex queries w/ around a dozen of graph patterns
(incl. paths & optional queries) and hundred of results complete in < 100
ms.

I will announce the release on this list once I'm comfortable with the
basic setup & have spent some quality time on documentation...
On 5 Aug 2013 18:13, "Timothy Baldridge"  wrote:

> This looks a re-implementation of many of the goals of Datomic. Perhaps
> you can use Datomic as a datastore, and then use Datomic's datalog, or a
> custom query engine (such as core.logic
> https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/datomic.clj)
> to do your queries?
>
> Timothy
>
>
> On Mon, Aug 5, 2013 at 10:52 AM, David Nolen wrote:
>
>> Very interesting. The rel feature is really still a bit of an
>> experimental thing and we'd like to replace it eventually with something
>> less problematic like pldb http://github.com/threatgrid/pldb.
>>
>> Still, core.logic isn't really a database and your needs may be better
>> served by something with different goals.
>>
>> David
>>
>>
>> On Mon, Aug 5, 2013 at 12:41 PM, Mingli Yuan wrote:
>>
>>> Hi, folks,
>>>
>>> After one night quick work, I had gave a proof-of-concept to demonstrate
>>> the feasibility that we can combine Wikidata and Clojure logic programming
>>> together.
>>>
>>> The source code is at here:
>>> https://github.com/mountain/knowledge
>>>
>>> An example of an entity:
>>>
>>> https://github.com/mountain/knowledge/blob/master/src/entities/albert_einstein.clj
>>>
>>> Example of types:
>>> https://github.com/mountain/knowledge/blob/master/src/meta/types.clj
>>>
>>> Example of predicates:
>>> https://github.com/mountain/knowledge/blob/master/src/meta/properties.clj
>>>
>>> Example of inference:
>>> https://github.com/mountain/knowledge/blob/master/test/knowledge/test.clj
>>>
>>> Also we found it is very easy to get any other language version than
>>> English.
>>>
>>> Since I am new to Clojure logic programming, I have questions for the
>>> way I take - what will happen when we have millions of triples? Should
>>> I take another approach by using some RDF store?
>>>
>>>- How many memory will it cost?
>>>- How about the performance?
>>>- How about the loading process of one million clojure source file
>>>or java class file?
>>>
>>> Hope you can give some helpful comments. Thanks in advance.
>>>
>>> Regards,
>>> Mingli
>>>
>>> --
>>> --
>>> 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 

Re: Wrong documentation of contains?

2013-08-07 Thread Tassilo Horn
Marcus Lindner  writes:

> But the problem is, that this is not mentioned in the documentation of
> contains? I found so far :(.

Well, it kind of is: Only associative data structures (maps, sets,
records, vectors) have keys, lists and seqs (such as
APersistentMap$KeySeq) don't.  I guess the confusion comes that people
are used that myMap.keySet() returns a set (which is an associative data
structure) whereas (keys my-map) returns a seq, not a set.

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: Wrong documentation of contains?

2013-08-07 Thread Karsten Schmidt
The fact, that the docs refer to checking if a "key" is present in the
collection, should make it obvious which types are supported, no? Only
vectors, maps and sets have keys. Lists and seqs do not. Of course it never
hurts to be more explicit about it...
On 7 Aug 2013 12:49, "Marcus Lindner" 
wrote:

> Thanks.
>
> But the problem is, that this is not mentioned in the documentation of
> contains? I found so far :(.
> I had such a problem a long time ago and remember now which type of
> "collection" can be used with contains?. But after a time I will forget
> this again and will refer to the documentation. (And when I get the
> Exception I remember again.)
>
> And I think this question arise also more frequently.
>
> But then my assumption that the documentation of contains? is misleading
> is true. Is it possible to update the documentation for the next version?
>
>
>
>
>
>
> 2013/8/7 Baishampayan Ghose 
>
>> Hi,
>>
>> `contains?` only works with associative data-structures like maps &
>> vectors. If you want to find out if a sequence contains a specific
>> object then you need to use `some` paired with a set as a predicate.
>>
>> For example:
>>
>> (some #{3} '(1 2 3 4))
>>
>> Hope this helps.
>>
>> ~BG
>>
>>
>> On Wed, Aug 7, 2013 at 4:54 PM, Goldritter
>>  wrote:
>> > In an program I used the result of keys as an argument for a function
>> which
>> > verifies whether an object is in a passed collection or not.
>> > The result I got was following Exception:
>> > IllegalArgumentException contains? not supported on type:
>> > clojure.lang.APersistentMap$KeySeq  clojure.lang.RT.contains
>> (RT.java:724)
>> >
>> > What are the reasons behind this Exception?
>> >
>> > In the documentation of contains? it is written, that
>> > "Returns true if key is present in the given collection, otherwise
>> returns
>> > false."
>> > The examples on this page
>> > (http://clojuredocs.org/clojure_core/clojure.core/contains_q) and the
>> > parameter description indicates, that contains? accept any collection as
>> > argument.
>> >
>> > The result of keys is also a collection
>> > => (coll? (keys {:a "f" :b 23}))
>> > true
>> >
>> > So is this a bug or is there a reason behind the fact, that contains?
>> does
>> > not accept any collection?
>> > Or is the documentation wrong and it should nor be a collection as
>> argument
>> > but a set or a vector?
>> >
>> > Because I get the same Exception for a list, but not for a vector.
>> > The same for lists, which returns also true for coll?.
>> > => (coll? '(1 2 3 4))
>> > true
>> >
>> > => (contains? '(1 2 3 4) 3)
>> > IllegalArgumentException contains? not supported on type:
>> > clojure.lang.PersistentList  clojure.lang.RT.contains (RT.java:724)
>> >
>> > => (contains? [1 2 3 4] 3)
>> > true
>> >
>> > --
>> > --
>> > 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.
>> >
>> >
>>
>>
>>
>> --
>> Baishampayan Ghose
>> b.ghose at gmail.com
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To 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, 

Re: Wrong documentation of contains?

2013-08-07 Thread Jonathan Fischer Friberg
That's only obvious if you already know how it works.

Jonathan

On Wed, Aug 7, 2013 at 2:13 PM, Karsten Schmidt wrote:

> The fact, that the docs refer to checking if a "key" is present in the
> collection, should make it obvious which types are supported, no? Only
> vectors, maps and sets have keys. Lists and seqs do not. Of course it never
> hurts to be more explicit about it...
> On 7 Aug 2013 12:49, "Marcus Lindner" 
> wrote:
>
>> Thanks.
>>
>> But the problem is, that this is not mentioned in the documentation of
>> contains? I found so far :(.
>> I had such a problem a long time ago and remember now which type of
>> "collection" can be used with contains?. But after a time I will forget
>> this again and will refer to the documentation. (And when I get the
>> Exception I remember again.)
>>
>> And I think this question arise also more frequently.
>>
>> But then my assumption that the documentation of contains? is misleading
>> is true. Is it possible to update the documentation for the next version?
>>
>>
>>
>>
>>
>>
>> 2013/8/7 Baishampayan Ghose 
>>
>>> Hi,
>>>
>>> `contains?` only works with associative data-structures like maps &
>>> vectors. If you want to find out if a sequence contains a specific
>>> object then you need to use `some` paired with a set as a predicate.
>>>
>>> For example:
>>>
>>> (some #{3} '(1 2 3 4))
>>>
>>> Hope this helps.
>>>
>>> ~BG
>>>
>>>
>>> On Wed, Aug 7, 2013 at 4:54 PM, Goldritter
>>>  wrote:
>>> > In an program I used the result of keys as an argument for a function
>>> which
>>> > verifies whether an object is in a passed collection or not.
>>> > The result I got was following Exception:
>>> > IllegalArgumentException contains? not supported on type:
>>> > clojure.lang.APersistentMap$KeySeq  clojure.lang.RT.contains
>>> (RT.java:724)
>>> >
>>> > What are the reasons behind this Exception?
>>> >
>>> > In the documentation of contains? it is written, that
>>> > "Returns true if key is present in the given collection, otherwise
>>> returns
>>> > false."
>>> > The examples on this page
>>> > (http://clojuredocs.org/clojure_core/clojure.core/contains_q) and the
>>> > parameter description indicates, that contains? accept any collection
>>> as
>>> > argument.
>>> >
>>> > The result of keys is also a collection
>>> > => (coll? (keys {:a "f" :b 23}))
>>> > true
>>> >
>>> > So is this a bug or is there a reason behind the fact, that contains?
>>> does
>>> > not accept any collection?
>>> > Or is the documentation wrong and it should nor be a collection as
>>> argument
>>> > but a set or a vector?
>>> >
>>> > Because I get the same Exception for a list, but not for a vector.
>>> > The same for lists, which returns also true for coll?.
>>> > => (coll? '(1 2 3 4))
>>> > true
>>> >
>>> > => (contains? '(1 2 3 4) 3)
>>> > IllegalArgumentException contains? not supported on type:
>>> > clojure.lang.PersistentList  clojure.lang.RT.contains (RT.java:724)
>>> >
>>> > => (contains? [1 2 3 4] 3)
>>> > true
>>> >
>>> > --
>>> > --
>>> > 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.
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Baishampayan Ghose
>>> b.ghose at gmail.com
>>>
>>> --
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To 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.

Re: Wrong documentation of contains?

2013-08-07 Thread Jay Fields
contains? is possibly poorly named, contains-key? would probably have
avoided this entire issue. That said, I'd like to see contains? return
false for things where it doesn't make sense, longs, keywords, etc. For a
list, it seems like converting the list to a vectoc (via vec) would be a
reasonable solution, though I'm sure there's some side effect that I
haven't considered. Perf would be impacted, but this doesn't seem like the
kind of thing you'd want to do anyway, so having poor perf wouldn't be the
end of the world. At least it wouldn't exception out.


On Wed, Aug 7, 2013 at 8:14 AM, Jonathan Fischer Friberg <
odysso...@gmail.com> wrote:

> That's only obvious if you already know how it works.
>
> Jonathan
>
>
> On Wed, Aug 7, 2013 at 2:13 PM, Karsten Schmidt wrote:
>
>> The fact, that the docs refer to checking if a "key" is present in the
>> collection, should make it obvious which types are supported, no? Only
>> vectors, maps and sets have keys. Lists and seqs do not. Of course it never
>> hurts to be more explicit about it...
>>  On 7 Aug 2013 12:49, "Marcus Lindner" <
>> marcus.goldritter.lind...@gmail.com> wrote:
>>
>>> Thanks.
>>>
>>> But the problem is, that this is not mentioned in the documentation of
>>> contains? I found so far :(.
>>> I had such a problem a long time ago and remember now which type of
>>> "collection" can be used with contains?. But after a time I will forget
>>> this again and will refer to the documentation. (And when I get the
>>> Exception I remember again.)
>>>
>>> And I think this question arise also more frequently.
>>>
>>> But then my assumption that the documentation of contains? is misleading
>>> is true. Is it possible to update the documentation for the next version?
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2013/8/7 Baishampayan Ghose 
>>>
 Hi,

 `contains?` only works with associative data-structures like maps &
 vectors. If you want to find out if a sequence contains a specific
 object then you need to use `some` paired with a set as a predicate.

 For example:

 (some #{3} '(1 2 3 4))

 Hope this helps.

 ~BG


 On Wed, Aug 7, 2013 at 4:54 PM, Goldritter
  wrote:
 > In an program I used the result of keys as an argument for a function
 which
 > verifies whether an object is in a passed collection or not.
 > The result I got was following Exception:
 > IllegalArgumentException contains? not supported on type:
 > clojure.lang.APersistentMap$KeySeq  clojure.lang.RT.contains
 (RT.java:724)
 >
 > What are the reasons behind this Exception?
 >
 > In the documentation of contains? it is written, that
 > "Returns true if key is present in the given collection, otherwise
 returns
 > false."
 > The examples on this page
 > (http://clojuredocs.org/clojure_core/clojure.core/contains_q) and the
 > parameter description indicates, that contains? accept any collection
 as
 > argument.
 >
 > The result of keys is also a collection
 > => (coll? (keys {:a "f" :b 23}))
 > true
 >
 > So is this a bug or is there a reason behind the fact, that contains?
 does
 > not accept any collection?
 > Or is the documentation wrong and it should nor be a collection as
 argument
 > but a set or a vector?
 >
 > Because I get the same Exception for a list, but not for a vector.
 > The same for lists, which returns also true for coll?.
 > => (coll? '(1 2 3 4))
 > true
 >
 > => (contains? '(1 2 3 4) 3)
 > IllegalArgumentException contains? not supported on type:
 > clojure.lang.PersistentList  clojure.lang.RT.contains (RT.java:724)
 >
 > => (contains? [1 2 3 4] 3)
 > true
 >
 > --
 > --
 > 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.
 >
 >



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

Re: Wrong documentation of contains?

2013-08-07 Thread Tassilo Horn
Jay Fields  writes:

> For a list, it seems like converting the list to a vectoc (via vec)
> would be a reasonable solution, though I'm sure there's some side
> effect that I haven't considered. Perf would be impacted, but this
> doesn't seem like the kind of thing you'd want to do anyway, so having
> poor perf wouldn't be the end of the world. At least it wouldn't
> exception out.

IMHO, it would be bad if converting lists (and seqs?) to vectors would
be done under the hoods.  There are high chances that you accidentally
pass a seq/list to `contains?` and then suffer from worse performance
without actually noticing.  E.g. you do something like

(contains? (map fuddle blabla) 3) ;; has at least 4 items

where you actually wanted to do

(contains? (mapv fuddle blabla) 3) ;; has at least 4 items

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: Wrong documentation of contains?

2013-08-07 Thread Lee Spector

On Aug 7, 2013, at 8:22 AM, Jay Fields wrote:

> contains? is possibly poorly named, contains-key? would probably have avoided 
> this entire issue.

I'd put it more strongly -- contains? is definitely poorly named, inviting the 
assumption that it can be used where you really want "some" with a set as the 
predicate. I've made the mistake myself and so have my students, many times. So 
now I single this out for a special warning in my classes, saying that the name 
is misleading so beware. I guess it's too late to do anything about it now, but 
I think this name was clearly a mistake.

 -Lee

-- 
-- 
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: Wrong documentation of contains?

2013-08-07 Thread Jay Fields
I ran into a similar (in my opinion) issue the other day.

I was working a vector and updating a value at a specific index. Ordering
and performance were important, so it seemed like a good default choice.

(-> [1 2 3] (update-in [1] inc))

Then the code changed a bit, I needed to filter some elements out. I ended
up with code similar to what's below

(-> (filter odd? [1 2 3])
(update-in [1] inc))

The above code fails, since my vector becomes a lazyseq.

I solved the issue in a different way, but I was a bit disappointed that
using filter caused me to have to move away from updating at an index.



On Wed, Aug 7, 2013 at 9:45 AM, Jay Fields  wrote:

> that's kind of my point, you wouldn't use contains? with a list 99.99% of
> the time (you probably want some), so if the perf is terrible while you're
> figuring out that you want some, it doesn't matter.
>
>
> On Wed, Aug 7, 2013 at 9:39 AM, Jeremy Heiler wrote:
>
>> On August 7, 2013 at 9:02:51 AM, Tassilo Horn (t...@gnu.org) wrote:
>>
>> Jay Fields  writes:
>>
>> > For a list, it seems like converting the list to a vectoc (via vec)
>> > would be a reasonable solution, though I'm sure there's some side
>> > effect that I haven't considered. Perf would be impacted, but this
>> > doesn't seem like the kind of thing you'd want to do anyway, so having
>> > poor perf wouldn't be the end of the world. At least it wouldn't
>> > exception out.
>>
>> IMHO, it would be bad if converting lists (and seqs?) to vectors would
>> be done under the hoods. There are high chances that you accidentally
>> pass a seq/list to `contains?` and then suffer from worse performance
>> without actually noticing. E.g. you do something like
>>
>> (contains? (map fuddle blabla) 3) ;; has at least 4 items
>>
>> where you actually wanted to do
>>
>> (contains? (mapv fuddle blabla) 3) ;; has at least 4 items
>>
>> I'm not sure any conversion should take place. The confusion with vectors
>> is that (contains? [1 2 3 4] 3) returns true because there are four
>> elements, not because 3 is present. So by returning false, false
>> assumptions are being validated in various cases.
>>
>>
>>
>

-- 
-- 
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: PoC: Combining Wikidata and Clojure logic programming

2013-08-07 Thread Mingli Yuan
Thanks very much, David, Timothy and Karsten,

I know some RDF store like Jena or Stardog, but the reason I want to take a
try of Clojure logic programming is the simplicity:

* setup for core.logic is very easy by lein
* no server needed
* and even from the concept level, Semantic Web is based on Description
logic  which is purely
logic things.

Maybe the simplicity is very nice for some special use cases.
But I don't know whether the idea is practical if the size of the triple
set is very large.

Right now I am downloading the wikidata database which contains millions of
entities and more triples.
I will try different approach, and benchmark them.

I am new to this area, and trying to learn more! Thanks again.

Regards,
Mingli




On Wed, Aug 7, 2013 at 7:53 PM, Karsten Schmidt wrote:

> Hi Mingli,
>
> FYI for the past 3 months I've been working almost fulltime on a
> lightweight, modular RDF Clojure toolkit, which I plan to opensource in the
> near future, once the core API has more solidified. The kit so far features:
>
> * core RDF datatype protocols (URIs, blank nodes, literals, containers &
> XSD type handling via multimethods)
> * simple & named graphs, datasets of multiple graphs
> * protocol based triple store implementations: in-memory (Clojure data
> structures), Redis, Cassandra (WIP)
> * SPARQL style query & update engine:
>   ** queries currently expressed as Clojure expressions
>   ** SPARQL syntax parser (WIP)
>   ** customizable query optimizations
>   ** fixed-length property paths
>   ** basic federation queries
>   ** optional queries
>   ** filter expressions, binding injection, grouping, sorting
> * graph -> tree mapper to turn a set of triples into nested object maps
> * rule based inferencing
>   ** supplied rule set of common OWL/RDFS semantics
> * streaming Turtle & JSON-LD IO, SPARQL result export as CSV, XML & JSON
> * customizable CSV -> RDF conversion
>
> Current focus of development:
> * SPARQL HTTP endpoint & protocol implementation
> * Streamed reasoning/inferencing w/ SPARQL-T
> * Extend support of OWL semantics in query engine
> * SPIN support, allowing queries, constraints & inference rules to be
> defined in RDF
> * async distributed query processor
> * Library of AngularJS visualization directives/components of SPARQL
> results (written in CLJS)
>
> In terms of performance, I can't unfortunately share yet any real
> benchmark results since I've only recently started looking into that for
> some core components, but IMHO things are looking promising (and obviously
> still have lengths to go). E.g. Using the in-memory store, the standard
> LUBM dataset with 1 uni & 105k triples loads in avg. 4.8 secs on a 2010
> MBP. With the Redis store (using the fabulous Carmine lib), the same loads
> in under 11 secs, but I know this will be a lot faster once I've switched
> to batching. So far the query engine has only been tested with smaller
> datasets (around 20k triples) and medium complex queries w/ around a dozen
> of graph patterns (incl. paths & optional queries) and hundred of results
> complete in < 100 ms.
>
> I will announce the release on this list once I'm comfortable with the
> basic setup & have spent some quality time on documentation...
> On 5 Aug 2013 18:13, "Timothy Baldridge"  wrote:
>
>> This looks a re-implementation of many of the goals of Datomic. Perhaps
>> you can use Datomic as a datastore, and then use Datomic's datalog, or a
>> custom query engine (such as core.logic
>> https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/datomic.clj)
>> to do your queries?
>>
>> Timothy
>>
>>
>> On Mon, Aug 5, 2013 at 10:52 AM, David Nolen wrote:
>>
>>> Very interesting. The rel feature is really still a bit of an
>>> experimental thing and we'd like to replace it eventually with something
>>> less problematic like pldb http://github.com/threatgrid/pldb.
>>>
>>> Still, core.logic isn't really a database and your needs may be better
>>> served by something with different goals.
>>>
>>> David
>>>
>>>
>>> On Mon, Aug 5, 2013 at 12:41 PM, Mingli Yuan wrote:
>>>
 Hi, folks,

 After one night quick work, I had gave a proof-of-concept to
 demonstrate the feasibility that we can combine Wikidata and Clojure logic
 programming together.

 The source code is at here:
 https://github.com/mountain/knowledge

 An example of an entity:

 https://github.com/mountain/knowledge/blob/master/src/entities/albert_einstein.clj

 Example of types:
 https://github.com/mountain/knowledge/blob/master/src/meta/types.clj

 Example of predicates:

 https://github.com/mountain/knowledge/blob/master/src/meta/properties.clj

 Example of inference:

 https://github.com/mountain/knowledge/blob/master/test/knowledge/test.clj

 Also we found it is very easy to get any other language version than
 English.

 Since 

Marginalia needs a new home

2013-08-07 Thread Fogus
As I mentioned on my blog[1], I'm looking to transfer ownership of the 
Marginalia codebase to someone interested in taking it in new and exciting 
directions.  I still value library documentation but I have long since 
become a mere user of my own software.  That is, what Marginalia does right 
now is exactly what I need it to do.  Therefore, if **you** have great 
ideas about making Marginalia something more and you're interested in 
taking over Marginalia (and lein-marginalia) development then contact me at 
me -at- fogus -dot- me.

[1]: http://blog.fogus.me/2013/08/07/marginalia-needs-a-home/

-- 
-- 
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: Wrong documentation of contains?

2013-08-07 Thread Jim - FooBar();
aa the old 'why  contains? doesn't work' discussion...even though 
it's been a while since it last came up on this list, it must be the 
single most popular questions :)



Jim


On 07/08/13 12:24, Goldritter wrote:
In an program I used the result of keys as an argument for a function 
which verifies whether an object is in a passed collection or not.

The result I got was following Exception:
IllegalArgumentException contains? not supported on type: 
clojure.lang.APersistentMap$KeySeq  clojure.lang.RT.contains (RT.java:724)


What are the reasons behind this Exception?

In the documentation of contains? it is written, that
"Returns true if key is present in the given collection, otherwise 
returns false."
The examples on this page 
(http://clojuredocs.org/clojure_core/clojure.core/contains_q) and the 
parameter description indicates, that contains? accept any collection 
as argument.


The result of keys is also a collection
=> (coll? (keys {:a "f" :b 23}))
true

So is this a bug or is there a reason behind the fact, that contains? 
does not accept any collection?
Or is the documentation wrong and it should nor be a collection as 
argument but a set or a vector?


Because I get the same Exception for a list, but not for a vector.
The same for lists, which returns also true for coll?.
=> (coll? '(1 2 3 4))
true

=> (contains? '(1 2 3 4) 3)
IllegalArgumentException contains? not supported on type: 
clojure.lang.PersistentList  clojure.lang.RT.contains (RT.java:724)


=> (contains? [1 2 3 4] 3)
true
--
--
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: PoC: Combining Wikidata and Clojure logic programming

2013-08-07 Thread Karsten Schmidt
That's also the exact same reason why I started this project in Clojure.
Being able to have no dependencies apart from tiny core libs
(tools.dependency, data.json) and use the REPL to play around with queries,
quickly import & export datasets, visualize results and not having to deal
with the complex class hierarchies of Jena/Sesame makes all the
difference... I too was playing around with core.logic in the beginning,
but found it didn't suit my use cases as much as I'd hoped and so
implemented my own query engine which is less general purpose, but maybe
more suitable for this kind of data and allows writing queries in a style
closer to SPARQL/Datomic/Datalog. This is in no way a criticism of
core.logic, though.

On 7 August 2013 15:10, Mingli Yuan  wrote:
> Thanks very much, David, Timothy and Karsten,
>
> I know some RDF store like Jena or Stardog, but the reason I want to take
a
> try of Clojure logic programming is the simplicity:
>
> * setup for core.logic is very easy by lein
> * no server needed
> * and even from the concept level, Semantic Web is based on Description
> logic which is purely logic things.
>
> Maybe the simplicity is very nice for some special use cases.
> But I don't know whether the idea is practical if the size of the triple
set
> is very large.
>
> Right now I am downloading the wikidata database which contains millions
of
> entities and more triples.
> I will try different approach, and benchmark them.
>
> I am new to this area, and trying to learn more! Thanks again.
>
> Regards,
> Mingli
>
>
>
>
> On Wed, Aug 7, 2013 at 7:53 PM, Karsten Schmidt 
> wrote:
>>
>> Hi Mingli,
>>
>> FYI for the past 3 months I've been working almost fulltime on a
>> lightweight, modular RDF Clojure toolkit, which I plan to opensource in
the
>> near future, once the core API has more solidified. The kit so far
features:
>>
>> * core RDF datatype protocols (URIs, blank nodes, literals, containers &
>> XSD type handling via multimethods)
>> * simple & named graphs, datasets of multiple graphs
>> * protocol based triple store implementations: in-memory (Clojure data
>> structures), Redis, Cassandra (WIP)
>> * SPARQL style query & update engine:
>> ** queries currently expressed as Clojure expressions
>> ** SPARQL syntax parser (WIP)
>> ** customizable query optimizations
>> ** fixed-length property paths
>> ** basic federation queries
>> ** optional queries
>> ** filter expressions, binding injection, grouping, sorting
>> * graph -> tree mapper to turn a set of triples into nested object maps
>> * rule based inferencing
>> ** supplied rule set of common OWL/RDFS semantics
>> * streaming Turtle & JSON-LD IO, SPARQL result export as CSV, XML & JSON
>> * customizable CSV -> RDF conversion
>>
>> Current focus of development:
>> * SPARQL HTTP endpoint & protocol implementation
>> * Streamed reasoning/inferencing w/ SPARQL-T
>> * Extend support of OWL semantics in query engine
>> * SPIN support, allowing queries, constraints & inference rules to be
>> defined in RDF
>> * async distributed query processor
>> * Library of AngularJS visualization directives/components of SPARQL
>> results (written in CLJS)
>>
>> In terms of performance, I can't unfortunately share yet any real
>> benchmark results since I've only recently started looking into that for
>> some core components, but IMHO things are looking promising (and
obviously
>> still have lengths to go). E.g. Using the in-memory store, the standard
LUBM
>> dataset with 1 uni & 105k triples loads in avg. 4.8 secs on a 2010 MBP.
With
>> the Redis store (using the fabulous Carmine lib), the same loads in
under 11
>> secs, but I know this will be a lot faster once I've switched to
batching.
>> So far the query engine has only been tested with smaller datasets
(around
>> 20k triples) and medium complex queries w/ around a dozen of graph
patterns
>> (incl. paths & optional queries) and hundred of results complete in < 100
>> ms.
>>
>> I will announce the release on this list once I'm comfortable with the
>> basic setup & have spent some quality time on documentation...
>>
>> On 5 Aug 2013 18:13, "Timothy Baldridge"  wrote:
>>>
>>> This looks a re-implementation of many of the goals of Datomic. Perhaps
>>> you can use Datomic as a datastore, and then use Datomic's datalog, or a
>>> custom query engine (such as core.logic
>>>
https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/datomic.clj
)
>>> to do your queries?
>>>
>>> Timothy
>>>
>>>
>>> On Mon, Aug 5, 2013 at 10:52 AM, David Nolen 
>>> wrote:

 Very interesting. The rel feature is really still a bit of an
 experimental thing and we'd like to replace it eventually with
something
 less problematic like pldb http://github.com/threatgrid/pldb.

 Still, core.logic isn't really a database and your needs may be better
 served by something with different goals.

 David


 On Mon, Aug 5, 2013 at 12:41 PM, Mingli Yuan 
 wrote:
>

[ANN] optparse-clj: Functional GNU-style command line options parsing

2013-08-07 Thread guns
Hello,

I'd like to announce optparse-clj, a command line options parser that
supports GNU option parsing conventions:

https://github.com/guns/optparse-clj

[guns.cli/optparse "1.0.0"]

The interface is modelled after clojure.tools.cli¹, but the parser is
more flexible:

* `-abc` expands to `-a -b -c`

* If -b requires an argument, `-abc` is parsed as `-a -b "c"`

* Long options are supported with and without equal signs:
  `--foo=bar` and `--foo bar`. `--foo=` is the same as `--foo ""`

* Trailing options are supported by default:

`arg -abc` == `-abc arg`

  But options can also be processed in order in the interest of
  building command hierarchies:

(parse argv cli-options :in-order true)

There is plenty of documentation, as well as a full sample program with
subcommands², so please check it out if you are building a command line
application.

guns

¹ https://github.com/clojure/tools.cli
² https://github.com/guns/optparse-clj/blob/master/test/example.clj


pgpEGEqY4sunO.pgp
Description: PGP signature


Re: Wrong documentation of contains?

2013-08-07 Thread Mark Engelberg
Yes, the discussion about contains? has come up before, but there's a new
aspect to this particular instance of the discussion that most of the posts
seem to be ignoring.

The original poster specifically pointed out that his sequence was
constructed by calling the `keys` function on a map:
(keys {:a "f" :b 23})

He then went on to point out that it doesn't return just a regular,
ordinary lazy sequence, but some sort of special type called a "KeySeq".

The documentation says that `contains?` looks for whether a given "key" is
present.  Probably when the documentation was written, there was some
assumption that by saying it looks for a "key", that makes it obvious it
only works on associative collections.

But look here, we've got a sequence of keys.  We know it is comprised of
keys, and obviously Clojure knows it is a sequence just of keys (because of
the custom type).  Therefore, it was reasonable for the poster to think
that `contains?` would work on to determine whether a given key was in the
collection -- it is a collection with keys!

So I think the new idea here, worthy of discussion, is this:

How can we reword the doc for `contains?` so that it clearly does not apply
to a sequence of keys?

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




Out of memory on spit

2013-08-07 Thread Jérémie Campari
Hello !

I don't understand why my code raise an Out of memory exception.

I have an agent that call a function which append a line to the "test.log" 
file. The out of memory is on PersistentHashMap $ 
BitmapIndexedNode.assoc(PersistentHashMap.java:624).

(use 'clojure.java.io)
>
 

> (def the-agent(agent nil))
>
 

> (defn process [_o content]
> (spit "test.log" content :append true)
> )

 

> (defn write-all []
> (doseq
> [x (range 1 500)]
> (send-off
> the-agent
> process
> "Line to be appended\n"
> )
> )
> )


 
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.




filter with a sequence of maps not working

2013-08-07 Thread Tilak Thapa
I'm new to clojure. I've return an utility function to filter a sequence of 
map by some key but it's not working. Here is the sample code - 

(def data [{:id 1 :b 2}
{:id 3 :b 4}
{:id 5 :b 6}
{:id 7 :b 8}])
In real app this is a sequence of maps read from csv file.

(defn get-data 
  [& attrs]
  (let [grps data]
(if (empty? attrs)
  grps
  (map #(select-keys % attrs) grps

(filter #(= (% :id) 7) (get-data :id :b))

Why above expression works but same expression wrapped as function (below) 
does not work?

(defn get-data-by-id [id & attrs]
  "always pass :id attribute"
(filter #(= (:id %) id) (get-data attrs)))

(get-data-by-id 3) ;; returns () this is probably ok (?) since :id key is 
not available
(get-data-by-id 3 :id :b) ;; returns () but why this does not work?

Pleas help me to figure this out.

thanks & cheers!
-tilak



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




Function as key of a map

2013-08-07 Thread Abraham
 this is in reference to the followng article 



http://blog.safaribooksonline.com/2013/08/06/two-simple-clojure-tricks-with-values/

wherin it says any value ( function , vector , other data structure of clj) 
can be used as key for a hashed map. 

can anybody enlighten how is it useful if function or any other data struc. 
is used as key?

Thnks
A

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




IDE feature

2013-08-07 Thread Abraham
Any IDE provides the feature found in DrRacket ,that is it auto completes 
the corresponding 

[  or  (  .  by pressing ) . Keep on pressing ) in DrRacket will 
autocomplete the square or round bracket.

Clojure IDE feature shld be for completing { , [  , ( ... and so on.

Thanks
A

-- 
-- 
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] optparse-clj: Functional GNU-style command line options parsing

2013-08-07 Thread Wolodja Wentland
On Wed, Aug 07, 2013 at 10:53 -0500, guns wrote:
> I'd like to announce optparse-clj, a command line options parser that
> supports GNU option parsing conventions:

> The interface is modelled after clojure.tools.cli¹, but the parser is
> more flexible:

Yes! Thank you so much for developing this and I am already grateful for it.

Do you have a particular reason why you didn't simply add this functionality
to tools.cli ?
-- 
Wolodja 

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature


Re: IDE feature

2013-08-07 Thread Mark Engelberg
I don't think there's any IDE that does this out of the box, although I'm
certain that if you're an elisp hacker, you could easily add this to emacs'
clojure mode.

I, too, miss that feature from DrRacket.

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




Story

2013-08-07 Thread Mark Engelberg
Recently, I discovered the "story" literate programming tool for Clojure,
which I prefer to marginalia:
https://github.com/jedahu/story

I had tried marginalia, but ran into the following problems:
1. Didn't really handle all markdown notations properly, so I had a lot of
trouble getting the formatting of the text to look right.
2. The code column wasn't wide enough and long lines of code didn't wrap,
so important things were just getting truncated.
3. As far as I could tell, there was no way to control what order the
various namespaces appeared in the uberdoc file.
4. Didn't build any sort of index.

I had never heard of "story", but ran across a mention of it while looking
through the issues on marginalia's github site, so I decided to give it a
try.  It's similar to marginalia, in that it's not true literate
programming -- it doesn't let you freely order your comments and code
irrespective of how they appear in the final files, but is a tool for
extracting long comments written in markdown in order to weave some sort of
narrative explanation of why the code is written the way it is.

I was really impressed with "story", and with a couple fairly minor
exceptions, it does exactly what I need it to do.

Has anybody else used story?
Does anybody know whether story is still being maintained?

The version on github is written in Clojure 1.2, and I couldn't get the
leiningen plugin (https://github.com/jedahu/lein-story) to work with a
current version of leiningen.  So I just cloned the repository from github
and compiled it locally, creating an executable jar to run.  Like I said,
it pretty much does what I want it to do out of the box, but I have some
reservations about writing all my code using a tool that might become
harder to use as Clojure and lein continue to evolve, assuming there are no
plans to further update the tool.

So, any thoughts about story?  Also, are there any other actively supported
documentation tools for Clojure that I should look at?  In addition to
marginalia and story, here's what I'm aware of:

In the literate programming department:
* org-babel (Only works with emacs.  Do stacktraces refer back to correct
file and line numbers?)
* Tim Daly posted a tool that lets him essentially write Clojure inside a
TeX document.  Seems to require a very different workflow to use
effectively.

In the API documentation department:
* autodoc (doesn't work on Windows last I checked)
* clodox (haven't tried, but looks good)

Right now, I care more about the literate programming side of things, but
I'm always interested in learning anything about good documentation tools
and practices for Clojure.

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: Out of memory on spit

2013-08-07 Thread Moritz Ulrich
Just a guess: You put 500 (or so) actions to the internal agent
queue and the agent isn't fast enough to keep up. The queue grows very
fast and goes out of memory.

On Wed, Aug 7, 2013 at 3:09 PM, Jérémie Campari
 wrote:
> Hello !
>
> I don't understand why my code raise an Out of memory exception.
>
> I have an agent that call a function which append a line to the "test.log"
> file. The out of memory is on PersistentHashMap $
> BitmapIndexedNode.assoc(PersistentHashMap.java:624).
>
>> (use 'clojure.java.io)
>
>
>>
>> (def the-agent(agent nil))
>
>
>>
>> (defn process [_o content]
>> (spit "test.log" content :append true)
>> )
>
>
>>
>> (defn write-all []
>> (doseq
>> [x (range 1 500)]
>> (send-off
>> the-agent
>> process
>> "Line to be appended\n"
>> )
>> )
>> )
>
>
>
> 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.




Re: filter with a sequence of maps not working

2013-08-07 Thread Timo Mihaljov
On 07.08.2013 10:58, Tilak Thapa wrote:
> (defn get-data 
>   [& attrs]
>   (let [grps data]
> (if (empty? attrs)
>   grps
>   (map #(select-keys % attrs) grps
> 
> (filter #(= (% :id) 7) (get-data :id :b))
> 
> Why above expression works but same expression wrapped as function
> (below) does not work?
> 
> (defn get-data-by-id [id & attrs]
>   "always pass :id attribute"
> (filter #(= (:id %) id) (get-data attrs)))
> 
> (get-data-by-id 3) ;; returns () this is probably ok (?) since :id key
> is not available
> (get-data-by-id 3 :id :b) ;; returns () but why this does not work?

`get-data-by-id` passes one argument to `get-data`: a sequence of
attributes. `get-data-by-id` expects one argument per attribute. Instead
of `(get-data attrs)`, use `(apply get-data attrs)`.

See http://clojuredocs.org/clojure_core/clojure.core/apply for examples
demonstrating the use of `apply`.

-- 
Timo

-- 
-- 
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] optparse-clj: Functional GNU-style command line options parsing

2013-08-07 Thread guns
On Wed  7 Aug 2013 at 05:35:41PM +0100, Wolodja Wentland wrote:

> Do you have a particular reason why you didn't simply add this
> functionality to tools.cli ?

I did think of sending this upstream, but the parser is not the only
point of difference with tools.cli. Given that both libraries are so
small, a patch would have rewritten a majority of the project.

Large patches require lots of convincing (and in this case, a
Contributer Agreement I have yet to submit), so I just wrote myself a
new implementation for a Clojure mail daemon I was writing.

tools.cli is, of course, free to swipe the parser from optparse-clj! I
would be happy to see it.

guns


pgpz00_ZBkWC_.pgp
Description: PGP signature


Re: IDE feature

2013-08-07 Thread Paul L. Snyder
>> On Wed, 07 Aug 2013, Abraham wrote:
>>
>> Any IDE provides the feature found in DrRacket ,that is it auto completes 
>> the corresponding 
> >
>> [  or  (  .  by pressing ) . Keep on pressing ) in DrRacket will 
>> autocomplete the square or round bracket.
>> 
>> Clojure IDE feature shld be for completing { , [  , ( ... and so on.
>
> On Wed, 07 Aug 2013, Mark Engelberg wrote:
>
> I don't think there's any IDE that does this out of the box, although I'm
> certain that if you're an elisp hacker, you could easily add this to emacs'
> clojure mode.
> 
> I, too, miss that feature from DrRacket.

When using Emacs with paredit: paredit-close-parenthesis (or, in fact, any
of paredit-close-round, paredit-close-square, and paredit-close-curly,
which should be bound to the corresponding keys by default) will jump to
past the closest closing delimiter, whether that closest delimiter is ')',
']', or '}'. This doesn't apply if you're in a string, comment, or
character literal, of course.

If paredit is a hard sell (it was for me, the first three or four times
that I tried it), realizing that you can break the "balance" when needed by
judicious use of kill and yank may be helpful during the transition to a
structural editing mindset.

Paul

-- 
-- 
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: IDE feature

2013-08-07 Thread Norman Richards
On Wed, Aug 7, 2013 at 12:25 PM, Paul L. Snyder wrote:

> If paredit is a hard sell (it was for me, the first three or four times
>  that I tried it), realizing that you can break the "balance" when needed
> by
> judicious use of kill and yank may be helpful during the transition to a
> structural editing mindset.


Structural editing, like paredit, is really the only sane way to do Clojure
code.  I honestly thing anyone who manually balances parenthesis or edits
Clojure functions in a way that doesn't preserve the structural integrity
of your expressions is just doing it wrong.  (not just doing it poorly -
but doing it wrong)

So, of course, my advice to the original poster is to just jump in and
learn paredit.  It will probably seem awkward at first, but if you invest
the effort (and it honestly doesn't take that much) to learn a better way
to edit expressions, you'll be so much better off.

In fact, I've sold several people on Clojure just by showing them how
paredit makes it significantly easier to lisp-style expressions than to
edit C-style languages with their irregular syntax.  I would jumped on lisp
years ago if I had realized how easy it was to edit instead of remembering
those painful university lisp assignments where I spent all my time
balancing parenthesis and being afraid to make simple structural changes
for fear of getting my code all messed up.

-- 
-- 
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: Wrong documentation of contains?

2013-08-07 Thread Michael Gardner
Wouldn't changing "collection" to "associative collection" be enough? Though 
maybe a note about its behavior on vectors would also be good.

On Aug 7, 2013, at 11:15 , Mark Engelberg  wrote:

> Yes, the discussion about contains? has come up before, but there's a new 
> aspect to this particular instance of the discussion that most of the posts 
> seem to be ignoring.
> 
> The original poster specifically pointed out that his sequence was 
> constructed by calling the `keys` function on a map:
> (keys {:a "f" :b 23})
> 
> He then went on to point out that it doesn't return just a regular, ordinary 
> lazy sequence, but some sort of special type called a "KeySeq".
> 
> The documentation says that `contains?` looks for whether a given "key" is 
> present.  Probably when the documentation was written, there was some 
> assumption that by saying it looks for a "key", that makes it obvious it only 
> works on associative collections.
> 
> But look here, we've got a sequence of keys.  We know it is comprised of 
> keys, and obviously Clojure knows it is a sequence just of keys (because of 
> the custom type).  Therefore, it was reasonable for the poster to think that 
> `contains?` would work on to determine whether a given key was in the 
> collection -- it is a collection with keys!
> 
> So I think the new idea here, worthy of discussion, is this:
> 
> How can we reword the doc for `contains?` so that it clearly does not apply 
> to a sequence of keys?
> 
> -- 
> -- 
> 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: Wrong documentation of contains?

2013-08-07 Thread Jonathan Fischer Friberg
No, it should be more explicit.

"If called with a map..."
"If called with a vector..."

Jonathan

On Wed, Aug 7, 2013 at 8:32 PM, Michael Gardner  wrote:

> Wouldn't changing "collection" to "associative collection" be enough?
> Though maybe a note about its behavior on vectors would also be good.
>
> On Aug 7, 2013, at 11:15 , Mark Engelberg 
> wrote:
>
> > Yes, the discussion about contains? has come up before, but there's a
> new aspect to this particular instance of the discussion that most of the
> posts seem to be ignoring.
> >
> > The original poster specifically pointed out that his sequence was
> constructed by calling the `keys` function on a map:
> > (keys {:a "f" :b 23})
> >
> > He then went on to point out that it doesn't return just a regular,
> ordinary lazy sequence, but some sort of special type called a "KeySeq".
> >
> > The documentation says that `contains?` looks for whether a given "key"
> is present.  Probably when the documentation was written, there was some
> assumption that by saying it looks for a "key", that makes it obvious it
> only works on associative collections.
> >
> > But look here, we've got a sequence of keys.  We know it is comprised of
> keys, and obviously Clojure knows it is a sequence just of keys (because of
> the custom type).  Therefore, it was reasonable for the poster to think
> that `contains?` would work on to determine whether a given key was in the
> collection -- it is a collection with keys!
> >
> > So I think the new idea here, worthy of discussion, is this:
> >
> > How can we reword the doc for `contains?` so that it clearly does not
> apply to a sequence of keys?
> >
> > --
> > --
> > 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: [ANN] optparse-clj: Functional GNU-style command line options parsing

2013-08-07 Thread Laurent PETIT
Le mercredi 7 août 2013, guns a écrit :

> On Wed  7 Aug 2013 at 05:35:41PM +0100, Wolodja Wentland wrote:
>
> > Do you have a particular reason why you didn't simply add this
> > functionality to tools.cli ?
>
> I did think of sending this upstream, but the parser is not the only
> point of difference with tools.cli. Given that both libraries are so
> small, a patch would have rewritten a majority of the project.
>
> Large patches require lots of convincing (and in this case, a
> Contributer Agreement I have yet to submit), so I just wrote myself a
> new implementation for a Clojure mail daemon I was writing.
>
> tools.cli is, of course, free to swipe the parser from optparse-clj! I
> would be happy to see it.


This cannot happen as you describe, afaik.

 code destined to go in contrib must be explicitly submitted by its author
(not just "pulled"), and the author must have signed and sent a contributor
agreement.

Cheers,

Laurent


> guns
>

-- 
-- 
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: Wrong documentation of contains?

2013-08-07 Thread Armando Blancas
The keys docstring says it returns a sequence, and that's all you get: 
it'll do first and next, nothing special about it. The contains? docstring 
says it won't do a linear search, so that rules out the result of keys. 
(KeySeq just wraps a seq of entries to return the key field.)

What's confusing to me here is that coll? will return true on a sequence.

On Wednesday, August 7, 2013 9:15:54 AM UTC-7, puzzler wrote:
>
> Yes, the discussion about contains? has come up before, but there's a new 
> aspect to this particular instance of the discussion that most of the posts 
> seem to be ignoring.
>
> The original poster specifically pointed out that his sequence was 
> constructed by calling the `keys` function on a map:
> (keys {:a "f" :b 23})
>
> He then went on to point out that it doesn't return just a regular, 
> ordinary lazy sequence, but some sort of special type called a "KeySeq".
>
> The documentation says that `contains?` looks for whether a given "key" is 
> present.  Probably when the documentation was written, there was some 
> assumption that by saying it looks for a "key", that makes it obvious it 
> only works on associative collections.
>
> But look here, we've got a sequence of keys.  We know it is comprised of 
> keys, and obviously Clojure knows it is a sequence just of keys (because of 
> the custom type).  Therefore, it was reasonable for the poster to think 
> that `contains?` would work on to determine whether a given key was in the 
> collection -- it is a collection with keys!
>
> So I think the new idea here, worthy of discussion, is this:
>
> How can we reword the doc for `contains?` so that it clearly does not 
> apply to a sequence of keys?
>

-- 
-- 
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: Clojure Stored Procedure

2013-08-07 Thread ArturoH
+1 here. Has anyone been able to write stored procedures in Java?

-- 
-- 
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.async channel GUID

2013-08-07 Thread David Pollak
Howdy,

I'm working on bridging between core.async channels in the browser and on
the server. It would be very useful to have a GUID associated with the
channel so that when I serialize a message that contains a channel, I can
send the GUID instead and on the other side, create a proxy channel so that
the client or server and send a reply message to the channel and it will be
sent over the wire.

Would it be possible to add a GUID to the channel?

Thanks,

David

-- 
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framework http://liftweb.net
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im

-- 
-- 
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.async channel GUID

2013-08-07 Thread Brandon Bloom
You can emulate this relatively easily with a pair of serialize/deserialize 
functions which read/write to a global atom containing a map.

On Wednesday, August 7, 2013 7:15:55 PM UTC-4, David Pollak wrote:
>
> Howdy,
>
> I'm working on bridging between core.async channels in the browser and on 
> the server. It would be very useful to have a GUID associated with the 
> channel so that when I serialize a message that contains a channel, I can 
> send the GUID instead and on the other side, create a proxy channel so that 
> the client or server and send a reply message to the channel and it will be 
> sent over the wire.
>
> Would it be possible to add a GUID to the channel?
>
> Thanks,
>
> David
>
> -- 
> Telegram, Simply Beautiful CMS https://telegr.am
> Lift, the simply functional web framework http://liftweb.net
> Follow me: http://twitter.com/dpp
> Blog: http://goodstuff.im
>
>  

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

2013-08-07 Thread Tim Daly
> Recently, I discovered the "story" literate programming tool for Clojure,
> which I prefer to marginalia:
> https://github.com/jedahu/story
> 
> ... (snip) ...
> 
> I had never heard of "story", but ran across a mention of it while looking
> through the issues on marginalia's github site, so I decided to give it a
> try.  It's similar to marginalia, in that it's not true literate
> programming -- it doesn't let you freely order your comments and code
> irrespective of how they appear in the final files, but is a tool for
> extracting long comments written in markdown in order to weave some sort of
> narrative explanation of why the code is written the way it is.

The ability to freely order comments and code is actually vital to the
idea of literate programming. The key idea is writing to communicate
ideas to another person. This almost certainly involves reordering
and restructuring code. The machinery needed to support literate
programming is trivial. See
http://axiom-developer.org/axiom-website/litprog.html

> ... (snip) ...

> * Tim Daly posted a tool that lets him essentially write Clojure inside a
> TeX document.  Seems to require a very different workflow to use
> effectively.

Actually it isn't really a change in workflow but a change in mindset.
Literate programming is not documentation, they are different ideas.

> Right now, I care more about the literate programming side of things, but
> I'm always interested in learning anything about good documentation tools

If you want the full-on Sturm und Drang see my talk at the WriteTheDocs
conference in April (Literate Programming in the Large):
http://www.youtube.com/watch?v=Av0PQDVTP4A

I gave a similar talk at the Clojure conference a couple years ago.

> and practices for Clojure.

For Clojure specific efforts see
http://daly.axiom-developer.org/clojure.pdf (PDF)
http://daly.axiom-developer.org/clojure.pamphlet (source)

Download the source, follow the one-time instructions which are 
  clip out and compile the "tangle" C program
  clip out the Makefile

When you type 'make' it will recreate Clojure's Java directory
structure, compile Clojure, run all the test cases, rebuild the PDF,
and put you in the REPL.

Your workflow is now:
 
 edit the source (clojure.pamphlet)
 loop-forever:
   type make
   fiddle with the REPL, clip the slime result into the source
   write a couple sentences

You'll soon discover that writing code and writing explanations are
co-equal activities, making the effort to write in a literate style
so much easier and natural. Oh, and you get a pretty book at the end.
Some PDF readers will update when changed so you can watch the book 
change as you work. I keep mine running so I can see the final book
after each time I run make.

Markdown, story, org-babel, javadoc, doxygen, and all of the other
"kinda-sorta-maybe-literatey" efforts miss the point as they try
to elevate "documentation" into what looks like a literate style
but fail to really address the point.

Really understanding lisp is an "epiphany moment" where you change
from asking "Why would anyone write like this?" to "Why doesn't 
everyone write like this?". Literate programming is the same kind
of epiphany event. It takes time but the results are worth it.

I'll see you on the other side.

Tim Daly


-- 
-- 
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: Function as key of a map

2013-08-07 Thread Matching Socks
Consider
  clojure.core/frequencies


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




Lisp newbie seeks (macro?) wisdom - instrumentation and app metadata

2013-08-07 Thread Jace Bennett
Thanks to the community for a wondrous programming environment. I
discovered SICP last year, and fell in love with the idea of lisp. But I've
come to a point where I think I need practice on moderately sized projects
before more reading will help.

When starting on almost any moderately scoped effort, I quickly run into a
class of problems which I think may be a fit for macros, but I want to
understand what is the idiomatic way to approach them in clojure.

Most of my professional experience is in .NET, and that is probably
coloring my thought patterns a bit. In that context, I often use reflection
scans and type metadata to configure infrastructural bits and dry things
up. Instead of having to explicitly register components in the more dynamic
areas of my app, I use conventions to select components to register from
the metadata I have about my code.

I can imagine using macros in clojure to accumulate metadata about my
declarations so that I can query them at runtime. For example, maybe a
"defendpoint" macro that sets up a handler AND adds it to the routing table
(or more directly an "endpoint map" which I then use to make routing
decisions among other things).

Admittedly, something about the sound of the phrase "it's just data" tells
me I'm sniffin up the wrong tree here. But I don't know how to turn that
nagging feeling into working code.

Is this a reasonable use of the macro? What about doing the registration at
macro-expansion time vs emitting runtime code to do it? How should one
approach the problems space otherwise?

Thanks for your time.

-- 
-- 
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: IDE feature

2013-08-07 Thread Lee Spector

On Aug 7, 2013, at 2:06 PM, Norman Richards wrote:
> Structural editing, like paredit, is really the only sane way to do Clojure 
> code.  I honestly thing anyone who manually balances parenthesis or edits 
> Clojure functions in a way that doesn't preserve the structural integrity of 
> your expressions is just doing it wrong.  (not just doing it poorly - but 
> doing it wrong)

What a spectacularly annoying thing to say.

I've been coding in Lisp for close to 30 years and teaching Lisp off and on for 
about 20. I have used paredit many times over these decades but I dislike it 
intensely, both for my own coding and for my teaching. I have my reasons for 
this, which I could explain, but I have no interest in discouraging you or 
anyone else who finds it useful from using it. But I don't want to use it, and 
I don't see where you get off saying that I'm "doing it wrong" on account of 
this.

> So, of course, my advice to the original poster is to just jump in and learn 
> paredit.  It will probably seem awkward at first, but if you invest the 
> effort (and it honestly doesn't take that much) to learn a better way to edit 
> expressions, you'll be so much better off. 

Your mileage may vary!

> In fact, I've sold several people on Clojure just by showing them how paredit 
> makes it significantly easier to lisp-style expressions than to edit C-style 
> languages with their irregular syntax.  I would jumped on lisp years ago if I 
> had realized how easy it was to edit instead of remembering those painful 
> university lisp assignments where I spent all my time balancing parenthesis 
> and being afraid to make simple structural changes for fear of getting my 
> code all messed up.

In my own experience bracket-matching and auto-reindentation are indeed 
essential, and they make balancing parentheses and seeing the structure of the 
code almost effortless. I would personally have a hard time coding in any 
environment without these tools. But Paredit takes things further by 
interfering with the typing/cutting/pasting/sketching/brainstorming 
skills/habits that I've developed over my whole life and which I use in every 
other text-based application and environment, preventing me from treating 
programs as text -- which is how I sometimes really want to think of them, 
especially when I'm playing with ideas and sketching out code roughly.

Your mileage may vary! But that doesn't mean that either of us is doing it 
wrong.

 -Lee


--
Lee Spector, Professor of Computer Science
Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspec...@hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438

-- 
-- 
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: Lisp newbie seeks (macro?) wisdom - instrumentation and app metadata

2013-08-07 Thread Mikera
I'd suggest avoiding macros until you absolutely know that you need them. 
Usually they aren't necessary.

Prefer writing pure functions (without side effects) - these are easier to 
reason about, easier to test, simpler to write correctly and easier to plug 
together / compose via higher order functions.

For example, in your endpoint example I would probably just use three 
functions:
- a pure "add endpoint metadata to an endpoint map" function
- an impure "update endpoints" function that updates endpoints using an 
endpoint map
- a function that calls both of the above to declare and launch a new 
endpoint

There might be a few other helper functions as well but hopefully you get 
the idea.

On Thursday, 8 August 2013 03:19:15 UTC+1, Jace Bennett wrote:
>
> Thanks to the community for a wondrous programming environment. I 
> discovered SICP last year, and fell in love with the idea of lisp. But I've 
> come to a point where I think I need practice on moderately sized projects 
> before more reading will help.
>
> When starting on almost any moderately scoped effort, I quickly run into a 
> class of problems which I think may be a fit for macros, but I want to 
> understand what is the idiomatic way to approach them in clojure.
>
> Most of my professional experience is in .NET, and that is probably 
> coloring my thought patterns a bit. In that context, I often use reflection 
> scans and type metadata to configure infrastructural bits and dry things 
> up. Instead of having to explicitly register components in the more dynamic 
> areas of my app, I use conventions to select components to register from 
> the metadata I have about my code.
>
> I can imagine using macros in clojure to accumulate metadata about my 
> declarations so that I can query them at runtime. For example, maybe a 
> "defendpoint" macro that sets up a handler AND adds it to the routing table 
> (or more directly an "endpoint map" which I then use to make routing 
> decisions among other things).
>
> Admittedly, something about the sound of the phrase "it's just data" tells 
> me I'm sniffin up the wrong tree here. But I don't know how to turn that 
> nagging feeling into working code.
>
> Is this a reasonable use of the macro? What about doing the registration 
> at macro-expansion time vs emitting runtime code to do it? How should one 
> approach the problems space otherwise?
>
> Thanks for your time.
>

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