Re: 'connection reset by peer' when connecting to socket

2012-09-02 Thread Michael Wood
Hi

On 2 September 2012 02:02, larry google groups
lawrencecloj...@gmail.com wrote:
 This is probably more of a socket and network question than a Clojure
 question. I am learning Clojure and wanted to serve a web page through a
 simple app, mostly to teach myself how to put together such an app in
 Clojure. I grabbed the page on Wikipedia about mitochondria, and I compiled
 my app with that bundled in as a static resource. I figured I would serve
 that, it is biggest enough to offer a real test. On my local machine,
 everything works great. I can run:

 lein compile
 lein uberjar
 java -jar serve-pages-from-memory-1.0-standalone.jar   9000

 This gets it running on my Mac. If I then look at localhost:9000 in a
 browser, I see the whole page. Everything seems to be working perfectly.

 I have 2 servers in the Rackspace cloud, and I wanted to run this app on one
 and call it from another. So I upload the app to one server and then I ssh
 to the other server and I call it using wget. At this point problems start.
 wget has to call the page many times. The first several times it tries to
 call, it gets Connection reset by peer. Only on the 6th try does wget get
 the whole document, successfully.

 This is the output:

 wget -O tma.html --force-html http://www.tailormadeanswers.com:9000/
 --2012-09-01 19:52:54--  http://www.tailormadeanswers.com:9000/
 Resolving www.tailormadeanswers.com... 184.106.135.172
 Connecting to www.tailormadeanswers.com|184.106.135.172|:9000... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 515592 (504K) [text/html]
 Saving to: `tma.html'

 89% [=  ] 458,878 --.-K/s
 in 0.04s

 2012-09-01 19:52:54 (11.1 MB/s) - Read error at byte 458878/515592
 (Connection reset by peer). Retrying.
[...]
 --2012-09-01 19:53:09--  (try: 6)  http://www.tailormadeanswers.com:9000/
 Connecting to www.tailormadeanswers.com|184.106.135.172|:9000... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 515592 (504K) [text/html]
 Saving to: `tma.html'

 100%[===] 515,592 --.-K/s
 in 0.04s

 2012-09-01 19:53:09 (12.5 MB/s) - `tma.html' saved [515592/515592]


 I am confused by a number of things here. The document from Wikipedia is
 500k, but wget seems to imply that it got 10.6 megs?

Where did you get that from?  Wget says Read error at byte
458878/515592 or saved [515592/515592], so it clearly is expecting
the resource to be 515592 bytes.

Since your server doesn't support getting part of the resource, wget
can't ask for just the parts it hasn't got yet.  It has to download
the whole thing again if it fails.

 I am brainstorming a few things that might be wrong here: the response is
 too slow? some kind of multi-threading is needed to respond to the request
 in a timely manner?

I'm guessing the server closes the socket before the client has
received the whole response, but I'm not sure.  You do have the
flush in there, so I'm not sure what else would be needed.

 Any suggestions?

 This whole app is only 40 lines of code, and this is the important part:

 (defn serve-page [output]
   (let [content-length (count @parsed-page)]
   (. output println HTTP/1.1 200 OK)
   (. output println Content-Type: text/html; charset=UTF-8)
   (. output println Connection: close)
   (. output println (str Content-Length:  content-length))
   (. output println \r\n)
   (. output println @parsed-page)
   (. output flush)
   (. output close)))

 (defn parse-buffer [ everything-else]
   (with-open []
 (.toString (reduce #(.append %1 %2)
(StringBuffer.) (line-seq page-buffer)

 (defn listen-and-respond [server-socket service]
   (let [client (. server-socket accept)
 output (PrintWriter. (. client getOutputStream)) ]
 (service output)))

 (defn run-server [port]
   (let [server-socket (ServerSocket. port)]
 (while (not (. server-socket isClosed))
   (listen-and-respond server-socket serve-page

 (defn -main [ args]
   (let [port (Integer/parseInt (first args))]
 (swap! parsed-page parse-buffer)
 (println Server is starting)
 (println port:  port)
 (run-server port)))

 Any suggestions about what might be wrong?

-- 
Michael Wood esiot...@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


screencast corruption

2012-09-02 Thread Andrew Rafas
Hi!

I just wanted to watch this screencast (Clojure Sequences) as I really need 
that little table which compares C#, Java and Clojure sequences. However 
the video on this link seems to be like 5 seconds long instead of more than 
an hour. Can you fix it? Or do you have the slides somewhere?
http://blip.tv/clojure/clojure-sequences-740581

Thanks,
Andrew

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

IPersistentStack semantics and PersistentQueue

2012-09-02 Thread Philip Potter
Hi all,

Does IPersistentStack have defined stack semantics? I'm confused
because IPersistentStack defines peek and pop and (via
IPersistentCollection) conj. I had previously expected that peek and
pop would remove from the same end that conj adds to, as happens with
lists and vectors, in order to get last-in-first-out (LIFO) semantics.

I was therefore very surprised to discover that PersistentQueue
implements IPersistentStack, but with queue semantics instead! ie peek
and pop operate at the left, while conj operates at the right.

Why does PersistentQueue implement IPersistentStack? What does
IPersistentStack mean, if an implementor doesn't actually have to
define stack semantics? Is this by design or is it just an accident of
PersistentQueue implementing IPersistentList which in turn implements
IPersistentStack? Is it something which would just be too awkward to
work around?

I notice also that Agent's ActionQueue has an IPersistentStack q field
which holds a PersistentQueue, which indicates that someone at least
is comfortable with this relationship. Does this indicate that
IPersistentStack's semantics simply mean a collection which can be
added to and removed from, in no particular order? Is
IPersistentStack the best name to describe this?

Phil

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


Re: screencast corruption

2012-09-02 Thread Mayank Jain
Confirmed. The video is indeed broken.

On Sun, Sep 2, 2012 at 3:34 PM, Andrew Rafas andras.ra...@gmail.com wrote:

 Hi!

 I just wanted to watch this screencast (Clojure Sequences) as I really
 need that little table which compares C#, Java and Clojure sequences.
 However the video on this link seems to be like 5 seconds long instead of
 more than an hour. Can you fix it? Or do you have the slides somewhere?
 http://blip.tv/clojure/clojure-sequences-740581

 Thanks,
 Andrew

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

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

Re: quick question about #'

2012-09-02 Thread nicolas.o...@gmail.com
I tend to like 1 better. I do not like working with vars without a good reason.

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


Re: screencast corruption

2012-09-02 Thread Ben Smith-Mannschott
I can't fix the version posted on blip.tv, but I downloaded it over a
year ago when it was still working.

It's a 107 MB quicktime file encoded using H.264. Running time is 1
hour 14 minutes.

I could make it available somewhere, if that would help.

// Ben

On Sun, Sep 2, 2012 at 12:37 PM, Mayank Jain firesof...@gmail.com wrote:
 Confirmed. The video is indeed broken.


 On Sun, Sep 2, 2012 at 3:34 PM, Andrew Rafas andras.ra...@gmail.com wrote:

 Hi!

 I just wanted to watch this screencast (Clojure Sequences) as I really
 need that little table which compares C#, Java and Clojure sequences.
 However the video on this link seems to be like 5 seconds long instead of
 more than an hour. Can you fix it? Or do you have the slides somewhere?
 http://blip.tv/clojure/clojure-sequences-740581

 Thanks,
 Andrew

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


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

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


Re: screencast corruption

2012-09-02 Thread Andrew Rafas
I would appreciate,
Thank you very much,
Andrew

On Sunday, September 2, 2012 4:19:10 PM UTC+1, bsmith.occs wrote:

 I can't fix the version posted on blip.tv, but I downloaded it over a 
 year ago when it was still working. 

 It's a 107 MB quicktime file encoded using H.264. Running time is 1 
 hour 14 minutes. 

 I could make it available somewhere, if that would help. 

 // Ben 

 On Sun, Sep 2, 2012 at 12:37 PM, Mayank Jain 
 fires...@gmail.comjavascript: 
 wrote: 
  Confirmed. The video is indeed broken. 
  
  
  On Sun, Sep 2, 2012 at 3:34 PM, Andrew Rafas 
  andras...@gmail.comjavascript: 
 wrote: 
  
  Hi! 
  
  I just wanted to watch this screencast (Clojure Sequences) as I really 
  need that little table which compares C#, Java and Clojure sequences. 
  However the video on this link seems to be like 5 seconds long instead 
 of 
  more than an hour. Can you fix it? Or do you have the slides somewhere? 
  http://blip.tv/clojure/clojure-sequences-740581 
  
  Thanks, 
  Andrew 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
  your first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 
  
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 


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

Re: quick question about #'

2012-09-02 Thread Moritz Ulrich
I usually store vars to functions when developing in the REPL. The
practical difference is that when you redefine `foo' in the above
example, calls via the `actions' map will use the old function as
the function itself ist stored, while after redefining `bar' calls
through `actions' will use the redefined function.

There are other benefits, as thread-local bindings etc. You can read
more about that on the http://clojure.org homepage.

On Sun, Sep 2, 2012 at 2:34 PM, nicolas.o...@gmail.com
nicolas.o...@gmail.com wrote:

 I tend to like 1 better. I do not like working with vars without a good
 reason.

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

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


Re: Question about sets

2012-09-02 Thread vemv
This issue best illustrates how imperative and functional thinking differ.

When I write code such as

(map not [true false])

, I implicitly think imperatively: compiler, please traverse this 
collection, applying 'not to each element
I could also word my thoughts functionally: I desire the filtering of 
mapping of reducing... but my mind just doesn't work like that. I suspect 
this applies to much people: it's not unusual to encounter the argument 
that our view of the world is essentially imperative.

While imperativeness typically gets some things wrong -e.g. time/change-, I 
believe we should't deny our imperative nature.

Just as in my previous example, when I encounter a set:

#{a b}

My first impression is to think about it as code, rather than data. It sure 
is data, and Clojure would remain correct under its current approach of 
throwing-on-duplicates, but this is a very unforgiving attitude towards 
what I deem our natural way of thinking.

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

Re: screencast corruption

2012-09-02 Thread Ben Smith-Mannschott
You should be able to download it from here for the next few days:

https://dl.dropbox.com/u/8238674/clojure-sequences.mov

// Ben

On Sun, Sep 2, 2012 at 6:56 PM, Andrew Rafas andras.ra...@gmail.com wrote:
 I would appreciate,
 Thank you very much,
 Andrew


 On Sunday, September 2, 2012 4:19:10 PM UTC+1, bsmith.occs wrote:

 I can't fix the version posted on blip.tv, but I downloaded it over a
 year ago when it was still working.

 It's a 107 MB quicktime file encoded using H.264. Running time is 1
 hour 14 minutes.

 I could make it available somewhere, if that would help.

 // Ben

 On Sun, Sep 2, 2012 at 12:37 PM, Mayank Jain fires...@gmail.com wrote:
  Confirmed. The video is indeed broken.
 
 
  On Sun, Sep 2, 2012 at 3:34 PM, Andrew Rafas andras...@gmail.com
  wrote:
 
  Hi!
 
  I just wanted to watch this screencast (Clojure Sequences) as I really
  need that little table which compares C#, Java and Clojure sequences.
  However the video on this link seems to be like 5 seconds long instead
  of
  more than an hour. Can you fix it? Or do you have the slides somewhere?
  http://blip.tv/clojure/clojure-sequences-740581
 
  Thanks,
  Andrew
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clo...@googlegroups.com
  Note that posts from new members are moderated - please be patient with
  your first post.
  To unsubscribe from this group, send email to
  clojure+u...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
 
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clo...@googlegroups.com
  Note that posts from new members are moderated - please be patient with
  your
  first post.
  To unsubscribe from this group, send email to
  clojure+u...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en

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

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


Status of the ClojureScript pluggable backend changes

2012-09-02 Thread Timothy Baldridge
What is the status of the Clojurescript pluggable backend? Are the latest
changes in the main trunk? Are their any plans to do this? I'd like to work
on an alternate back-end and I'd like to take advantage of this code.

Timothy

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

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

Re: Possible to merge destructuring :or defaults with :as?

2012-09-02 Thread Stephen Compall
On Fri, 2012-08-31 at 03:40 -0700, Peter Taoussanis wrote:
 (foo) = {:x x-default :y y-default}
 
 
 I.e. to merge the :or defaults over the :args binding?

Such behavior would be quite surprising; to see why, desugar :keys:

{x (expr-that-computes :x),
 y (expr-that-computes :y),
 z (expr-that-computes :z),
 :or {x x-default y y-default} :merge-as args}

which treats bindings as having bidirectional flow; we bind a name to
the value of a keyword, rewriting in the other direction if the value
isn't present.

Instead,

 Rationale:  one of the nice things of setting defaults via :or is that
 they're visible to callers via :arglists. This'd help make the process
 more convenient in the (relatively common) case where you'd like to
 preserve arbitrary args, but apply some defaults in a transparent way.

When you want this,

(let [{blah} (merge my-defaults kwargs)]

-- 
Stephen Compall
^aCollection allSatisfy: [:each | aCondition]: less is better than


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


Re: screencast corruption

2012-09-02 Thread Sean Corfield
Thanx Ben. That's the first time I've seen that preso and it really
does help things click regarding the seq abstraction!

On Sun, Sep 2, 2012 at 12:43 PM, Ben Smith-Mannschott
bsmith.o...@gmail.com wrote:
 You should be able to download it from here for the next few days:

 https://dl.dropbox.com/u/8238674/clojure-sequences.mov

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


Clojure / RootBeer / CUDA / GPU

2012-09-02 Thread Jules

Guys,

Has anyone read about RootBeer - https://github.com/pcpratts/rootbeer1

My understanding is that it can compile Java bytecode - CUDA GPU code.

A Java class that you want to run on your CUDA GPU must subclass the 
RootBeer Kernel interface.

So, I wondering what would happen if I

1) implement Kernel with some simple Clojure code that just e.g. adds a 
couple of numbers, get the class out onto disc, compile it with the 
Rootbeer compiler and try running the result on my GPU.

2) Pull the RootBeer compiler into a running Clojure image and figure out 
how to do the same thing on-the-fly.

3) Write e.g. (cuda-map f coll) which embeds f in a Kernel, copies the 
contents of coll and the new kernel up to your CUDA GPU and executes f on 
the contents of coll in parallel producing a new coll which is copied back 
into Clojure world and returned...

Of course, there are lots of things to be resolved here, I have only had 
time today to Compile up the CUDA download, clone the RootBeer git repo, 
compile it and try to run the example program - ArraySumApp. I got an error 
which I am thinking indicates that RootBeer doesn't like my 
1.7.0_03-icedtea-mockbuild_2012_06_13_11_56-b00 - the current version of 
Java on my Fedora16 box, but... think how much fun I could have with this 
little project :-).

Anyway, I thought I would just announce my intentions to play with this on 
the list, in case anyone else was interested or already doing so and 
fancied collaborating or, maybe someone will be able to tell me why it 
will never work and save me the effort :-)

all the best,


Jules


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

Advice/recommendations for generating templated (non-Clojure) s-expressions?

2012-09-02 Thread Don Jackson
‎
Hello,

I want to generate non-Clojure s-expressions in Clojure code, with a nice 
templating format (like syntax-quote provides), BUT with the option of 
providing my own methods/functions for
resolving/processing symbols, and the ability to provide my own 
methods/functions for evaluating syntax-quote escapes, e.g. ~, @.

Is there anything out there I can use?

Here is some background:

I have been playing around with generating SUO-KIF from Clojure code.

ontolog.cim3.net/file/resource/reference/SIGMA-kee/suo-kif.pdf

Here is an example SUO-KIF form:

(=
  (instance ?COMPANY Coffeeshop)
  (exists  (?SERVICE ?BEVERAGE)
(and
  (instance  ?SERVICE   CommercialService)
  (agent ?SERVICE   ?COMPANY)
  (instance  ?SERVICE   Selling)
  (patient   ?SERVICE   ?BEVERAGE)
  (instance  ?BEVERAGE  Coffee
I'd like to generate the above via a Clojure macro/function that would be 
called like this:

(sells Coffeeshop Coffee)

By defining sells something like this:

(defmacro-like-thing sells [kind-of-store product]
`(=
(instance ?COMPANY ~kind-of-store)
(exists  (?SERVICE ?PRODUCT))
…
))

My initial thought was this was going to be completely trivial, and I'd be done 
in 30 minutes maximum
and it is easy to generate something right away, but I am not at all happy
with the result, especially what the Clojure code templates look like.

It would be really nice if the resulting template would look very close to the 
resulting output, so that users of this tool (Ontologists, not programmers)
could easily see/specify the templates.  

My first thought was that I would use Clojure macros and syntax-quote to 
generate the SUO-KIF  s-expressions.  
To my way of thinking, syntax-quote is a very nice s-exp templating tool, what 
could be easier?
I quickly re-learned that macros are a really about generating Clojure, at read 
time, that is then eval'ed.
Two issues with that:
1) symbols in my template specification are 
resolved/namespace-qualified by syntax-quote, which is not what I want at all.
2) I don't want the resulting s-expression to be eval'ed by Clojure.  I 
can work around that by having the the macro return (quote s-exp), I guess.

I then tried using syntax-quote within a Clojure function, but again, 
syntax-quote is resolving/namespace-qualifying the symbols, 
and of course, a function's arguments are always evaluated on the way in, which 
leads to tedious and unpleasant quoting of SUO-KIF symbols.

I'd welcome any thoughts/pointers about how best to approach this.

Don



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

using take-while with pred function that has state

2012-09-02 Thread shaobohou
Hi,

I am trying to write a function which takes a list of strings, tokenize 
each one, and maximise N such that the number of unique tokens in the first 
N strings is less than 
some number M.

I have written the following function using take-while and a pred function 
with an atom to store the set of unique tokens. It works and is just as 
fast as a messier loop/recur version. 

(defn take-as-many-as-possible-until
  [ss tok-fn m]
  (let [items (atom #{})]
(- (fn [v]
  (swap! items (partial apply merge) (tok-fn v))
  ( (count @items) m))
 (take-while ss

However, I have noticed that the take-while documentation says that the 
pred function should be side-effect free. Will this be problem in my 
implementation if I am calling it from multiple threads? And what would be 
the more idiomatic way of implementing this kind of behaviour?

Thanks,
Shaobo



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

Problems with Leiningen and Clojure 1.4

2012-09-02 Thread Martin
Hi

Im having problems using Leiningen together with Clojure 1.4 (and 1.3) on 
Windows 7. Using Leiningen version 1.5.2 I can create a new project and use 
lein deps to download clojure version 1.2.1. However if I change 
dependencies in project.clj to org.clojure/clojure 1.4.0, I run into 
trouble. Running lein deps downloads clojure-1.4.0.jar to lib. Running lein 
repl gives:

Warning: *classpath* not declared dynamic and thus is not dynamically 
rebindable, but its name suggests otherwise. Please either indicate 
^:dynamic *classpath* or change the name. (NO_SOURCE_PATH:1)
REPL started; server listening on localhost:50497.

It starts up and gives me a prompt, but whatever I write at the prompt 
(even just enter) freezes the program, forcing me to exit with ctrl-c.

I also tried using Leiningen 2.0.0. It automatically creates a project with 
Clojure 1.3.0 as dependency. Running lein deps gives no error but I cant 
find Clojure 1.3.0 downloaded anywhere. There is a .lein folder in 
C:\Users\Martin which contains a couple of jars but not the main Clojure 
one. Running lein repl starts clojure 1.3.0 without errors, but as above, 
as soon as I type anything it freezes.

Any ideas?


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

Re: Code retreat exercices where Clojure could shine?

2012-09-02 Thread Alex Walker
If the audience is largely Java, then 
http://www.infoq.com/presentations/Clojure-Java-Interop ;

The isBlank refactoring starting at about 13:50 is worth considering as a 
starting point.

On Thursday, August 30, 2012 8:53:16 AM UTC-5, Denis Labaye wrote:



 On Thu, Aug 30, 2012 at 12:20 AM, Russell Whitaker 
 russell@gmail.comjavascript:
  wrote:

 Clojure is inherently shiny, no need to gild the lily.


 yes but it has parenthesis
  


 What's the purpose and duration of your code retreat?


 1 day 
 subjects are free
 the public is 1/3 convinced by clojure / other languages, the other 2/3 
 are not aware that there's something else than Java on the JVM
  


 Russell


 On Monday, August 27, 2012 2:41:20 AM UTC-7, Denis Labaye wrote:

 Hi,

 I am organizing a code retreat in September.

 All languages are accepted, I want to use Clojure for this time, which
 exercises would make Clojure shine?

 Thanks!

 Denis

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




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

Why IPersistentList doesn't extend ISeq?

2012-09-02 Thread Andrei Zhlobich
Why IPersistentList doesn't extend ISeq?

Clojure docs say:
  Lists are collections. They implement the ISeq interface directly 
(except for the empty list, which is not a valid seq)

At this moment EmptyList implements ISeq, but PersistentList doesn't. It 
seems very strange for me.
Also PersistentQueue implements IPersistentList, but semantically it is not 
a list.

I think we can do 2 changes in hierarchy:
1) extend IPersistentList from ISeq;
2) extend PersistentQueue directly from IPersistentStack instead of 
IPersistentList.

Is it possible?

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

Clojurescript keywords starting with numbers and read-string

2012-09-02 Thread Jens Haase
Hi,

I have a problem with read-string in Clojurescript. Reading keywords 
starting with a number will fail:

(cljs.reader/read-string :123)
(cljs.reader/read-string :1abc)

Both will return following error: Uncaught TypeError: Cannot read property 
'0' of null

I think this is a bug. Any suggestions?

Cheers,
Jens

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

Re: European conferences in 2012?

2012-09-02 Thread Andrew Jones
On 29 August 2012 14:08, Jonathan Lange j...@mumak.net wrote:
 Just wondering if there are any conferences in Europe coming up in the
 remainder of the year that would be of interest to someone interested
 in Clojure?

There's FP Days in Cambridge, UK on October 25th and 26th.
http://www.fpdays.net/fpdays2012/index.php

-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


How to run Clooj?

2012-09-02 Thread gearss
I am new to Clojure, I want to know how ot run the Clooj IDE? 
If it needs to install Clojure to my computer, or every time I use   
java -cp /path/to/the/clojure.jar clojure.main /path/to/your/code.clj
to run my code?

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

Why IPersistentList doesn't extend ISeq?

2012-09-02 Thread Andrei Zhlobich
From docs:
   Lists are collections. They implement the ISeq interface directly 
(except for the empty list, which is not a valid seq).

But at this time IPersistentList does not extend ISeq (but PersistentList 
does). It sees a bit strange.
Also PersistentQueue implements IPersistentList. Semantically queue differs 
from a list.

Is it possible to extend IPersistentList from ISeq and PersistentQueue from 
IPersistentStack instead of IPersistentList?

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

Problems importing java classes

2012-09-02 Thread Daniel Woelfel


I'm attempting to translate some exercises from the book Introduction to 
Computer Simulation Methods http://sip.clarku.edu/ from Java to Clojure.

First, I packaged up the opensourcephysics source 
codehttp://www.opensourcephysics.org/document/ServeFile.cfm?ID=7147DocID=2267#Doc2267and
 submitted it to clojars https://clojars.org/org.clojars.dwwoelfel/osp. 
The source is on Github https://github.com/dwwoelfel/opensourcephysics. 
Then I added it as a dependency to my project. Unfortunately, if I try to 
import a class from opensourcephysics, I get 
java.lang.ClassNotFoundException. I can't do lein compile without this 
error:

 Caused by: java.lang.ClassNotFoundException: 
 org.opensourcephysics.controls.AbstractSimulation
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at 
 clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:61)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Unknown Source)
 at clojure.lang.RT.classForName(RT.java:2039)
 at clojure.core$the_class.invoke(genclass.clj:99)
 at clojure.core$generate_class.invoke(genclass.clj:119)
 at clojure.core$gen_class.doInvoke(genclass.clj:622)
 at clojure.lang.RestFn.invoke(RestFn.java:1124)
 at clojure.lang.Var.invoke(Var.java:465)
 at clojure.lang.AFn.applyToHelper(AFn.java:248)
 at clojure.lang.Var.applyTo(Var.java:532)
 at clojure.lang.Compiler.macroexpand1(Compiler.java:6366)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6441)
 ... 45 more


It appears that I've declared dependencies incorrectly, or packaged up the 
opensourcephysics code incorrectly. 

My project.clj looks like

(defproject fractal 0.1.0-SNAPSHOT
   :description FIXME: write description
   :url http://example.com/FIXME;
   ;; Same license as opensourcephysics
   :license {:name GNU General Public License
 :url http://www.gnu.org/copyleft/gpl.html}
   :dependencies [[org.clojure/clojure 1.4.0]
  [org.clojars.dwwoelfel/osp 2.3]]
   :main fractal.fractalapp)


the fractal.fractalapp namespace declaration is:

(ns fractal.fractalapp
   (:import [org.opensourcephysics.frames PlotFrame]
[org.opensourcephysics.controls SimulationControl])
   (:gen-class :name org.opensourcephysics.controls.FractalApp
   :extends org.opensourcephysics.controls.AbstractSimulation))


The source is available on Github: https://github.com/dwwoelfel/fractal

I'm not sure if it is a problem with the way I declare dependencies or with 
the way I packed up the opensourcephysics code. 

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

I want to know how can I run it?

2012-09-02 Thread gearss
I have a file named pong.clj, it isunder following, I want to know how can 
I run it?
Thank you.
 

(ns example.game.pong
  (:use [penumbra opengl]
[clojure.contrib.def])
  (:require [penumbra [app :as app] [text :as text]]))
(def ball-width 0.03)
(def ball-height 0.03)
(def paddle-width 0.02)
(def paddle-height 0.15)
;;;
(defn abs [x] (Math/abs x))
(defn intersect-1d [[a b] [x y]]
  (and (= a y) (= b x)))
(defn intersect-2d [[a b c d] [x y z w]]
  (and (intersect-1d [a c] [x z])
   (intersect-1d [b d] [y w])))
(defn reflector [[x y w h] f]
  (let [r [x y (+ x w) (+ y h)]]
(fn [region velocity]
  (if (intersect-2d region r)
(f velocity)
velocity
(defvar boundaries
  [(reflector [0 -1 1 1] (fn [[x y]] [x (abs y)]))
   (reflector [0 1 1 1] (fn [[x y]] [x (- (abs y))]))
   (reflector [-1 0 1 1] (fn [[x y]] [(abs x) y]))
   (reflector [1 0 1 1] (fn [[x y]] [(- (abs x)) y]))])
(defn update-ball [state dt]
  (let [ball (concat (:p state) (map + (:p state) [ball-width ball-height]))
v (reduce
   #(%2 ball %1) (:v state)
   (conj
boundaries
(reflector [0.01 (:left state) paddle-width paddle-height]
   (fn [[x y]] [(abs x) y]))
(reflector [(- 0.99 paddle-width) (:right state) paddle-width 
paddle-height]
   (fn [[x y]] [(- (abs x)) y]]
(assoc state
  :v v
  :p (map + (:p state) (map (partial * dt) v)
(defn draw-ball [pos]
  (push-matrix
   (apply translate pos)
   (draw-quads
(vertex 0 0)
(vertex ball-width 0)
(vertex ball-width ball-height)
(vertex 0 ball-height
;;;
(defn update-opponent-paddle [state]
  (let [[x y] (:p state)
[vx vy] (:v state)
dt (/ (- 1 x) vx)
dy (- (+ y (* vy dt)) (:right state))]
(assoc state
  :v-right (if (neg? vx) 0 (/ dy dt)
(defn update-player-paddle [state]
  (assoc state
:v-left
(cond
 (app/key-pressed? :up) -1
 (app/key-pressed? :down) 1
 :else 0)))
(defn update-paddle [dt v pos]
  (min (- 1 paddle-height) (max 0 (+ pos (* dt v)
(defn draw-paddle [x y]
  (push-matrix
   (translate x y)
   (draw-quads
(vertex 0 0)
(vertex paddle-width 0)
(vertex paddle-width paddle-height)
(vertex 0 paddle-height
;;;
(defn reset-game [state]
  (assoc state
:v [0.4 0.8]
:p [0.5 0.5]
:left 0.5, :v-left 0.0
:right 0.5, :v-right 0.0))
(defn init [state]
  (app/vsync! true)
  (app/title! Pong)
  (app/periodic-update! 2 update-opponent-paddle)
  (reset-game state))
(defn reshape [[x y w h] state]
  (ortho-view 0 1 1 0 -1 1)
  state)
(defn update [[delta _] state]
  (- state
  (update-player-paddle)
  (assoc :left (update-paddle delta (:v-left state) (:left state)))
  (assoc :right (update-paddle delta (:v-right state) (:right state)))
  (update-ball delta)))
(defn display [[delta _] state]
  (draw-ball (:p state))
  (draw-paddle 0.01 (:left state))
  (draw-paddle (- 0.99 paddle-width) (:right state))
  (app/repaint!))
(defn start []
  (app/start
   {:display display, :reshape reshape, :update update, :init init}
   {}))
 

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

Reflecting over protocols in macros for clojurescript

2012-09-02 Thread Ceri Storey
Hi there.

I'm having a play around with ClojureScript, and I'd find it really useful
to be able to be able to create some Mockito style test spies. Ultimately,
I'd like to be able to generate a spy by reflecting over a protocol and
find out what operations it supports programatically.

However, now that I've looked core.cljs from the ClojureScript source code,
it doesn't seem like the compiler actually keeps track of which protocols
support which operations--is that right? Is there some other way of
discovering the operations that a cljs protocol supports, or would i need
to write my own analysis code for this?

Thanks,
-- 
Ceri Storey

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

Re: webnoir on openshift (Paas by RedHat), little guide

2012-09-02 Thread Raoul Duke
now if only they had a webinar that explained the utterly horrendous
leagaleze nightmare tolsoty-length terms and conditions.

On Fri, Aug 31, 2012 at 2:49 PM, John Holland jbholl...@gmail.com wrote:
 This is awesome!

 On Friday, August 31, 2012 4:31:38 PM UTC-4, Simone Mosciatti wrote:

 A little guide to use webnoir on openshift

 http://sisciatech.tumblr.com/post/29614188595/webnoir-in-openshift

 English is not my first language, if you find any mistake please let me
 know.

 I hope it will be useful to somebody.

 Simone

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

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


Re: Why IPersistentList doesn't extend ISeq?

2012-09-02 Thread Tamreen Khan
First, IPersistentSeq is the interface, PersistentSeq is the actual class.

If you look at it a little more closely, PersistentList extends ASeq, which
is an abstract class. ASeq implements the ISeq interface. So PersistentList
does implement ISeq through its parent class.

https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentList.java#L16
-
PersistentList extending ASeq
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ASeq.java#L16
-
ASeq implementing ISeq


On Fri, Aug 31, 2012 at 12:58 PM, Andrei Zhlobich a.zhlob...@gmail.comwrote:

 Why IPersistentList doesn't extend ISeq?

 Clojure docs say:
   Lists are collections. They implement the ISeq interface directly
 (except for the empty list, which is not a valid seq)

 At this moment EmptyList implements ISeq, but PersistentList doesn't. It
 seems very strange for me.
 Also PersistentQueue implements IPersistentList, but semantically it is
 not a list.

 I think we can do 2 changes in hierarchy:
 1) extend IPersistentList from ISeq;
 2) extend PersistentQueue directly from IPersistentStack instead of
 IPersistentList.

 Is it possible?

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

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

Re: Why IPersistentList doesn't extend ISeq?

2012-09-02 Thread Tamreen Khan
Sorry, I meant IPersistentList and PersistentList in the first sentence of
my previous email.

On Sun, Sep 2, 2012 at 11:00 PM, Tamreen Khan histor...@gmail.com wrote:

 First, IPersistentSeq is the interface, PersistentSeq is the actual class.

 If you look at it a little more closely, PersistentList extends ASeq,
 which is an abstract class. ASeq implements the ISeq interface. So
 PersistentList does implement ISeq through its parent class.


 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentList.java#L16
  -
 PersistentList extending ASeq

 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ASeq.java#L16
  -
 ASeq implementing ISeq


 On Fri, Aug 31, 2012 at 12:58 PM, Andrei Zhlobich a.zhlob...@gmail.comwrote:

 Why IPersistentList doesn't extend ISeq?

 Clojure docs say:
   Lists are collections. They implement the ISeq interface directly
 (except for the empty list, which is not a valid seq)

 At this moment EmptyList implements ISeq, but PersistentList doesn't. It
 seems very strange for me.
 Also PersistentQueue implements IPersistentList, but semantically it is
 not a list.

 I think we can do 2 changes in hierarchy:
 1) extend IPersistentList from ISeq;
 2) extend PersistentQueue directly from IPersistentStack instead of
 IPersistentList.

 Is it possible?

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




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

ANN: ClojureSphere updated

2012-09-02 Thread Justin Kramer
ClojureSphere has been updated with a new domain, refreshed index, and some 
new features:

http://www.clojuresphere.com/

ClojureSphere lets you browse the dependency graph of the open source 
Clojure ecosystem.

The dependency information is provides now is slightly more accurate and 
useful. There's also an API: http://www.clojuresphere.com/api

Ideas and contributions welcome: https://github.com/jkk/clojuresphere

Justin

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

Re: Advice/recommendations for generating templated (non-Clojure) s-expressions?

2012-09-02 Thread Maik Schünemann
Hi
If the sexp will not be evaluated from clojure code, why aren't you using a
function to generate the code instead of a macro. That avoids the namespace
resolution.

If you want to go with macros, there is a trick to turn namespace
resolution of. just unquote like this  @':
Am 03.09.2012 01:07 schrieb Don Jackson cloj...@clark-communications.com
:

 ‎
 Hello,

 I want to generate non-Clojure s-expressions in Clojure code, with a nice
templating format (like syntax-quote provides), BUT with the option of
providing my own methods/functions for
 resolving/processing symbols, and the ability to provide my own
methods/functions for evaluating syntax-quote escapes, e.g. ~, @.

 Is there anything out there I can use?

 Here is some background:

 I have been playing around with generating SUO-KIF from Clojure code.

 ontolog.cim3.net/file/resource/reference/SIGMA-kee/suo-kif.pdf

 Here is an example SUO-KIF form:

 (=
   (instance ?COMPANY Coffeeshop)
   (exists  (?SERVICE ?BEVERAGE)
 (and
   (instance  ?SERVICE   CommercialService)
   (agent ?SERVICE   ?COMPANY)
   (instance  ?SERVICE   Selling)
   (patient   ?SERVICE   ?BEVERAGE)
   (instance  ?BEVERAGE  Coffee

 I'd like to generate the above via a Clojure macro/function that would be
called like this:

 (sells Coffeeshop Coffee)

 By defining sells something like this:

 (defmacro-like-thing sells [kind-of-store product]
 `(=
 (instance ?COMPANY ~kind-of-store)
 (exists  (?SERVICE ?PRODUCT))
 …
 ))


 My initial thought was this was going to be completely trivial, and I'd
be done in 30 minutes maximum
 and it is easy to generate something right away, but I am not at all happy
 with the result, especially what the Clojure code templates look like.

 It would be really nice if the resulting template would look very close
to the resulting output, so that users of this tool (Ontologists, not
programmers)
 could easily see/specify the templates.

 My first thought was that I would use Clojure macros and syntax-quote to
generate the SUO-KIF  s-expressions.
 To my way of thinking, syntax-quote is a very nice s-exp templating tool,
what could be easier?
 I quickly re-learned that macros are a really about generating Clojure,
at read time, that is then eval'ed.
 Two issues with that:
 1) symbols in my template specification are resolved/namespace-qualified
by syntax-quote, which is not what I want at all.
 2) I don't want the resulting s-expression to be eval'ed by Clojure.  I
can work around that by having the the macro return (quote s-exp), I guess.

 I then tried using syntax-quote within a Clojure function, but again,
syntax-quote is resolving/namespace-qualifying the symbols,
 and of course, a function's arguments are always evaluated on the way in,
which leads to tedious and unpleasant quoting of SUO-KIF symbols.

 I'd welcome any thoughts/pointers about how best to approach this.

 Don



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

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

Re: using take-while with pred function that has state

2012-09-02 Thread Stephen Compall
On Fri, 2012-08-31 at 05:08 -0700, shaobohou wrote:
 I have written the following function using take-while and a pred
 function with an atom to store the set of unique tokens. It works

Only because in the current implementation, take-while happens to be
called in coll order, which is not a guarantee of the API.

 Will this be problem in my implementation if I am calling it from
 multiple threads?

No.

 And what would be the more idiomatic way of implementing this kind of
 behaviour?

Consider this restructuring:

(- ss (map tok-fn), (reductions (partial apply merge) #{}),
 (take-while #(...)), (map #(do %2 %1) ss), last)

Use of `atom' for this sort of thing is certainly an antipattern, so
consider any alternative that suits you.

-- 
Stephen Compall
^aCollection allSatisfy: [:each | aCondition]: less is better than


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


Re: Problems importing java classes

2012-09-02 Thread Stephen Compall
On Fri, 2012-08-31 at 22:22 -0700, Daniel Woelfel wrote:
 Caused by: java.lang.ClassNotFoundException:
 org.opensourcephysics.controls.AbstractSimulation

 (ns fractal.fractalapp
   (:import [org.opensourcephysics.frames PlotFrame]
[org.opensourcephysics.controls SimulationControl])
   (:gen-class :name
 org.opensourcephysics.controls.FractalApp
   :extends
 org.opensourcephysics.controls.AbstractSimulation))

You should import AbstractSimulation before you try to reference it from
gen-class.

-- 
Stephen Compall
^aCollection allSatisfy: [:each | aCondition]: less is better than


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