Change platform for reader conditionals

2018-07-18 Thread Nikita Beloglazov
Hi

Is it possible to read a string containing reader conditionals using a
platform different from "current". In particular in from clojure I want to
read a string that contains :cljs reader conditionals and evaluate them as
if current platform is cljs.

Example: if I run the following code from clj:

(read-string {:read-cond :allow} "#?(:clj 1 :cljs 2)")

then I get 1. But I want to get 2. Is there a way to do it in Clojure
somehow or maybe using tools.reader?

Thanks,
Nikita

-- 
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/d/optout.


[ANN] Quil 2.7.1 Release

2018-04-01 Thread Nikita Beloglazov
Happy to announce Quil 2.7.1 release.
Quil is a Clojure/ClojureScript library for creating interactive drawings
and animations.

The release available on clojars: http://clojars.org/quil. List of changes:

   -

   Add resize-sketch function. #212
   .
   -

   Add :enable/disable-async-saveframe hints. Thanks to Jacob Maine.
   -

   Add display-ads function to embed advertising in sketches to make a few
   bucks while sharing your art. Docs
   .
   -

   Pass event object to key-released handler in fun-mode. #209
   .
   -

   Disable automatic setting of pixel density to be screen density. #202
   .
   -

   Fix not working titles. See #236
   . Thanks to @mishadoff
   .
   -

   Fix random-2d and random-3d to produce uniformly distributed vectors.
   Commit
   

   .
   -

   Update to Processing 3.3.7 and Processing.js to 1.6.6.
   -

   Partial Java 9 support. Doesn't work on Mac OS. See Processing plan
   
   for Java 9 support.

Documentation on http://quil.info has been updated.

Happy hacking!
Nikita

-- 
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/d/optout.


Re: [QUIL] select-input and select-output?

2017-04-16 Thread Nikita Beloglazov
Glad to hear you worked it out. Feel free to contribute your implementation
of select-input/output/folder to Quil.

Nikita

On Sun, Apr 16, 2017 at 2:52 AM Jay Porcasi  wrote:

> hello Nikita,
> your example worked great!
> and i was able to 'abstract' it into a select-input function that i can
> call to set the file-path
> hopefully it will be straightforward to do the same for select-output and
> select-folder
> by the way it would be great if something like that was available in quil
> by default
> thank you a lot for your help,
> Jay
>
>
> On Thursday, April 13, 2017 at 8:20:21 PM UTC+7, Jay Porcasi wrote:
>>
>> thank you Nikita!
>>
>> i will try your example to understand it better
>>
>> a simple file chooser that returns the file path as string is all i need
>> actually, i don't get all the complication in Processing of passing a
>> callback function but i guess it must be there for a reason
>>
>> cheers,
>> Jay
>>
>> --
> 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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/R61OvE4jYEc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/d/optout.


Re: [QUIL] select-input and select-output?

2017-04-12 Thread Nikita Beloglazov
Hi Jay

No, there is no native support of selectInput() or selectOutput() in Quil. 
You can try calling Processing's methods directly using java interop. 
Though it's not straightforward. The problem is that when you call 
selectInput() you have to pass a name of callback function to be called. 
This name is just a string and Processing finds corresponding method using 
reflection and invokes it. To make it work we need to generate a class, 
let's say FileCallback which has method onFileSelected(). Then we need to 
pass instance of that class to selectInput() along with "onFileSelected" as 
callback name. 

Here is an 
example: https://gist.github.com/nbeloglazov/8a74fa3e6bbb44137df27c4a5201ad1e 
If you're not familiar with generating classes in clojure then check docs 
 it's non-trivial. 

Hope this helps,
Nikita

On Monday, April 10, 2017 at 8:49:09 PM UTC-7, Jay Porcasi wrote:
>
> hello,
>
> i'm looking for the Quil equivalents of Processing selectInput() and 
> selectOutput() but i can't find them
>
> if they're not there, what would be the best way to directly access the 
> corresponding Processing methods instead?
> or is there a different more convenient way to get the same functionality 
> of those methods?
>
> thanks for any suggestions in the right direction
> Jay
>

-- 
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/d/optout.


Re: livecoding with Quil middleware

2017-03-23 Thread Nikita Beloglazov
Yes, middleware runs exactly once so you can't redefine it. In the example 
with fill-background you can redefine fill-backgfound:

 (def fill-background [draw-fn] (draw-fn))

Which essentially makes it identify. So that's would be my recommendation: 
put all logic to fill-background and let fill-background-middleware be just 
a wrapper like it is now. 

On Wednesday, March 22, 2017 at 8:22:59 PM UTC-7, Jay Porcasi wrote:
>
> hi Nikita
>
> thank you so much for your explanation, it's very clear (and a bit 
> surprising to learn that partial and anonymous functions have a slightly 
> different semantics)
>
> i am able to get the live coding behaviour when i redefine fill-background 
> (as 
> per your example, and that's great that it is possible)
>
> however it seems not possible to get a live coding behaviour when 
> redefining fill-background-middleware (the middleware function itself)
>
> for example i would love if i could evaluate:
> (def fill-background-middleware identity)
> and see the background reverting to what it was before (that's just an 
> example)
>
> but this seems not possible because that middleware runs just once, when 
> the sketch is initialized
>
> do i understand correctly?
> and is it something that would not be achievable by any other means? (one 
> more level of indirection perhaps? :-)
>
> Jay
>
>
>
> On Monday, March 20, 2017 at 11:09:35 AM UTC+7, Nikita Beloglazov wrote:
>>
>> Hi Jay
>>
>> Yes, draw and update functions support live coding out-of-box. It's 
>> trickier with middleware. The main thing is that middleware run once, when 
>> initializing sketch. The goal of middleware is to take user provided 
>> settings (like draw and update funcitons), optionally wrap some of them in 
>> another functions and return new settings. It depends on your middleware 
>> implementation whether it supports live coding. As a simple example let's 
>> say you have a simple middleware that fills background with some color 
>> before each draw. Here is how you can do it so it supports live reloading:
>>
>> (defn fill-background [draw-fn]
>>   (q/background 255)
>>   (draw-fn))
>>
>> (defn fill-background-middleware [options]
>>   (let [user-draw (:draw options)]
>> (assoc options
>>   :draw #(fill-background user-draw
>>
>> (q/defsketch abc
>>   :draw ...
>>   :middleware [fill-background-middleware])
>>
>> If you try changing 'fill-background', for example change color from 255 
>> to 200, then you should see effect immediately. The trick is on line 
>>
>> :draw #(fill-background user-draw
>>
>> Here we say that new draw function is an anonymous function that calls 
>> fill-background. So on each draw invocation it will lookup fill-background 
>> function by name. If you reload this function - name will stay the same, 
>> but implementation changes and interpreter pick ups new function. On the 
>> other hand if you do following:
>>
>> :draw (partial fill-background user-draw)
>>
>> Then you won't get live reloading. Even though these 2 approaches 
>> essentially do the same, the second approach actually "remembers" original 
>> version of fill-background. If you try changing that function it won't have 
>> effect as interpreter no longer looks up function by name. 
>>
>> I'm probably not explaining it very well but I hope it's still helpful. 
>> If you still have problems with your middleware - feel free to post the 
>> code in this thread and I'll take a look.
>>
>> Nikita
>>
>> On Friday, March 17, 2017 at 7:50:02 PM UTC-7, Jay Porcasi wrote:
>>>
>>> hello, i hope this is the place to discuss questions about Quil (i 
>>> couldn't find a dedicated forum)
>>>
>>> and first of all, kudos to Nikita for this incredible library, which i 
>>> find even better than the original Processing
>>> it's not just a matter of using a different syntax than java, but Nikita 
>>> actually created something more powerful and flexible than Processing
>>>
>>> i'm particularly fond of the middleware functionality, which is a stroke 
>>> of genius: so simple in retrospect and so powerful, opening a whole new way 
>>> of possibilities of structuring one's own work in a modular fashion
>>>
>>> so i have one question regarding live coding and middleware
>>>
>>> if i redefine a function that i associate to :setup, :update or :draw 
>>> keys, i can see my running sketch changing on the fly, reflecting the new 
>>> definitions
>>>
&g

Re: livecoding with Quil middleware

2017-03-19 Thread Nikita Beloglazov
Hi Jay

Yes, draw and update functions support live coding out-of-box. It's 
trickier with middleware. The main thing is that middleware run once, when 
initializing sketch. The goal of middleware is to take user provided 
settings (like draw and update funcitons), optionally wrap some of them in 
another functions and return new settings. It depends on your middleware 
implementation whether it supports live coding. As a simple example let's 
say you have a simple middleware that fills background with some color 
before each draw. Here is how you can do it so it supports live reloading:

(defn fill-background [draw-fn]
  (q/background 255)
  (draw-fn))

(defn fill-background-middleware [options]
  (let [user-draw (:draw options)]
(assoc options
  :draw #(fill-background user-draw

(q/defsketch abc
  :draw ...
  :middleware [fill-background-middleware])

If you try changing 'fill-background', for example change color from 255 to 
200, then you should see effect immediately. The trick is on line 

:draw #(fill-background user-draw

Here we say that new draw function is an anonymous function that calls 
fill-background. So on each draw invocation it will lookup fill-background 
function by name. If you reload this function - name will stay the same, 
but implementation changes and interpreter pick ups new function. On the 
other hand if you do following:

:draw (partial fill-background user-draw)

Then you won't get live reloading. Even though these 2 approaches 
essentially do the same, the second approach actually "remembers" original 
version of fill-background. If you try changing that function it won't have 
effect as interpreter no longer looks up function by name. 

I'm probably not explaining it very well but I hope it's still helpful. If 
you still have problems with your middleware - feel free to post the code 
in this thread and I'll take a look.

Nikita

On Friday, March 17, 2017 at 7:50:02 PM UTC-7, Jay Porcasi wrote:
>
> hello, i hope this is the place to discuss questions about Quil (i 
> couldn't find a dedicated forum)
>
> and first of all, kudos to Nikita for this incredible library, which i 
> find even better than the original Processing
> it's not just a matter of using a different syntax than java, but Nikita 
> actually created something more powerful and flexible than Processing
>
> i'm particularly fond of the middleware functionality, which is a stroke 
> of genius: so simple in retrospect and so powerful, opening a whole new way 
> of possibilities of structuring one's own work in a modular fashion
>
> so i have one question regarding live coding and middleware
>
> if i redefine a function that i associate to :setup, :update or :draw 
> keys, i can see my running sketch changing on the fly, reflecting the new 
> definitions
>
> this is not the case however if i redefine a function that i use as a 
> middleware
>
> is it an intrinsic limitation? would it be possible to extend the live 
> coding behaviour to middlewares as well?
>
> thanks and long live Quil,
> Jay
>
>

-- 
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/d/optout.


[ANN] Quil 2.6.0 Release

2017-02-12 Thread Nikita Beloglazov
Happy to announce Quil 2.6.0 release.
Quil is a Clojure/ClojureScript library for creating interactive drawings
and animations.

The release available on clojars: https://clojars.org/quil. List of changes:

   - Add random-2d and random-2d functions to generate random vectors. #201
    by @prakhar1989
   
   - Fix current-fill and current-stroke on cljs. #196
    by @satchit8
   
   - Fix mouse-pressed? and key-pressed? on cljs. #198
    by @Norgat
   
   - Fix console.log problem that logged every call to rect. Bug
   .
   - Update Processing to 3.2.4 and Processing.js to 1.6.4.

Documentation on http://quil.info has been updated as well.

Happy hacking!

Nikita

-- 
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/d/optout.


Re: Good Clojure Projects for the Classroom?

2017-02-06 Thread Nikita Beloglazov
I taught similar course at a college. I gave exercises from 4clojure so 
that students can get used to writing clojure. Also I prepared few 
"home-made" 
problems: https://github.com/nbeloglazov/clojure-interactive-tasks. Though 
these are not projects that students do completely by themselves as they 
already have "ui" for problems and students have to only implement 
solution. But it might help to come up with your own ideas. 

Nikita

On Monday, February 6, 2017 at 3:03:46 PM UTC-8, Eddie wrote:
>
> Recently I began teaching a college level course that uses Clojure. We 
> have made it through the lectures on the lisp syntax, the data types, 
> collections, and immutability. Now I would like to ask the students to 
> apply their new Clojure knowledge to a small project. (Something that could 
> be completed in about week if worked on for an hour a day). 
>
> Does anyone know of any good resources for such projects? Any ideas are 
> much appreciated!
>

-- 
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/d/optout.


[ANN] Quil 2.5.0 Release

2016-11-05 Thread Nikita Beloglazov
Happy to announce Quil 2.5.0 release.
Quil is a Clojure/ClojureScript library for creating interactive drawings
and animations.

The release available on clojars: https://clojars.org/quil. List of changes:

   - Support svg rendering. #188 .
   - Add do-record  macro to
   simplify svg/pdf generation. #189
   .
   - Update Processing to 3.2.2 and Processing.js to 1.6.3.
   - Fix mouse-wheel event propagation outside of sketch. #175
   
   - Fix reflection warnings. #185 

Since 2.5.0 Quil works only on Java 8+ because Processing 3.2.2 doesn't
support Java 7 and below.

Documentation on http://quil.info has been updated as well.

Happy hacking!
Nikita

-- 
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/d/optout.


Re: Clojure version and quil

2016-09-07 Thread Nikita Beloglazov
Hi Jerome

That's odd. Can you post project.clj generated from "lein new quil 
drawing"? In my case it generates 
this: https://gist.github.com/nbeloglazov/511afe2e43213b0ae7bb51ec73e20169

What version of lein do you have (run "lein version")? 

Nikita

On Tuesday, September 6, 2016 at 2:00:35 PM UTC+3, Jerome Manceau wrote:
>
> Hi,
>
> I'm very new to Clojure and hitting a wall trying to use quil.
>
> I've created a new project following an example "lein new quil drawing"
> It seemed to work but when checking the project.clj I saw that the quil 
> dependency was missing.
> Also, trying to start a first test application would only throw errors.
>
> Now, I realised that I need clojure version >= 1.7 to have quil working.
> But that's where it gets confusing:
>
> - When typing "clojure" in my terminal, I get : Clojure 1.4.0
>
> - When starting "lein repl" and then typing "(clojure-version)", I get: 
> "1.2.1"
>
> - When using the REPL on my IDE (NightCode) and typing "(clojure-version), 
> I get: "1.9.0-alpha11"
>
> So, how do I upgrade the clojure version in leiningen, so that I can call 
> "lein new quil drawing" and get the project created properly?
>
> I'm working on ubuntu 14.4
>
> Thanks for help
>

-- 
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/d/optout.


Re: [ANN] Quil 2.4.0 and improved live editor

2016-03-26 Thread Nikita Beloglazov
> FYI: The quil.info site has a broken link. The "Quil Intro" links to:
> http://nbeloglazov.com/2014/05/29/quil-intro.html
> But that's 404.
> Alan

Thanks for reporting, Alan. I was doing some work on nbeloglazov.com and 
accidentally broke it. It should be working now. 


> Do we have examples of where people are using Quil ?

I believe people mostly using it for doing sketches/art. Also Quil is often 
used for teaching clojure, for example ClojureBridge: 
https://github.com/ClojureBridge/drawing and talk from last year clojure conj: 
https://www.youtube.com/watch?v=n0yN1GauxCA=PLZdCLR02grLrl5ie970A24kvti21hGiOf=7

Nikita

-- 
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/d/optout.


[ANN] Quil 2.4.0 and improved live editor

2016-03-24 Thread Nikita Beloglazov
Happy to announce Quil 2.4.0 release.

Quil is a Clojure/ClojureScript library for creating interactive drawings
and animations.

The release available on clojars: https://clojars.org/quil. List of changes:

   - Updated cheatsheet
   .
   Thanks to @SevereOverfl0w .
   - Added support for some new processing functions: pixel-density,
   display-density, clip, no-clip, key-modifiers.
   - Fixes: #170 , #179
   .
   - Upgraded to ProcessingJS 1.4.16 and Processing 3.0.2.
   - Drop support of Clojure 1.6.0.
   - Migrated from cljx to cljc and various refactorings to make Quil
   compile with self-hosted cljs.

Documentation on http://quil.info has been updated as well.

*Live editor*

Editor  on quil.info was revamped and
migrated to self-hosted ClojureScript! That means that now you can evaluate
code ~instantly in browser and even reevaluate parts of code. Editor
provides following features:


   - full client-side compilation including macros from quil.core;
   - partial evaluation: use Ctrl+Enter to evaluate selected code or form
   under cursor
   - warning and error messages;
   - easy sketch sharing via URL;

Feedback and bug reports are welcome! Feel free to reply to this thread or
file a bug in Quil repo .


Happy hacking!

Nikita

-- 
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/d/optout.


[ANN] Quil 2.3.0 Release

2015-12-01 Thread Nikita Beloglazov
Happy to announce Quil 2.3.0 release.
Quil is a Clojure/ClojureScript library for creating interactive drawings
and animations.

The release available on clojars: https://clojars.org/quil. List of changes:

   - Migrated to Processing 3.0. See relevant Processing page
   .
   - Switch to Clojure 1.6. Makes it incompatible with Clojure 1.5.1.
   - Optimizations in helper seqs functions. See #160
   .
   - Fix #161 : don't draw text
   when no-fill is set.
   - Fix #115 : bind *out* to REPL
   to make errors more visible when using emacs.
   - Removed few hints (due to Processing 3.0): :enable-retina-pixels,
   :disable-retina-pixels, :enable-native-fonts, :disable-native-fonts.

Documentation on http://quil.info has been updated as well.

Upgrade to Processing 3.0 didn't introduce major API changes. The most
noticeable change is that now smooth and no-smooth functions must be called
inside new handler :settings (a cousin of :setup). See settings()
documentation  for
Processing.

Happy hacking!
Nikita

-- 
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/d/optout.


[ANN] Quil 2.2.6 Release

2015-06-03 Thread Nikita Beloglazov
Happy to announce Quil 2.2.6 release.

Quil is a Clojure/ClojureScript library for creating interactive drawings
and animations. Github repo https://github.com/quil/quil.

The release available on clojars: https://clojars.org/quil. Changes:

   - Fix bug with hex colours. Issue #71
   https://github.com/quil/quil/issues/71.
   - Make with-translation and with-rotation macros handle exceptions
   properly. Issue #154 https://github.com/quil/quil/issues/154. (thanks
   to rbuchmann https://github.com/rbuchmann)
   - Fix blend-color function in cljs. Issue #156
   https://github.com/quil/quil/issues/156.
   - Add Navigation 2D middleware. See docs
   https://github.com/quil/quil/blob/master/src/cljx/quil/middleware.cljx#L93
   .
   - Pass draw/update/other functions by name, not by value in cljs to make
   live-reloading easier (for example with figwheel).

Happy hacking!
Nikita

-- 
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/d/optout.


[ANN] Quil 2.2.5 Release

2015-01-31 Thread Nikita Beloglazov
Happy to announce Quil 2.2.5 release.

Quil is a Clojure/ClojureScript library for creating interactive drawings
and animations. Github repo https://github.com/quil/quil.

The release available on clojars: https://clojars.org/quil. This is a minor
release with only 2 changes:

   - Support global-key-events option for cljs sketch. It allows sketches
   to listen to all key events even if sketch doesn't have focus.
   - Use latest cljs capabilites to simplify setting up cljs project: no
   more externs, preamble and easy-to-use :none optimization level.

More about second change:

You no longer need to specify externs or preamble files in project.clj and
no need to include processing.js file on a page if you did. Everything will
be wired up automatically by clojurescript so advanced compilation is a
piece of cake now: just change optimizations to :advanced and that's all.

Using :none optimization level became easier: you no longer need to change
html page to switch between none and other level. quil-cljs template has
been updated to use :none so you can try it out to see how it works. Just
run lein quil-cljs my-sketch.

Note that Quil 2.2.5 supports only clojurescript 0.0-2727 and above.

Documentation on http://quil.info has been updated as well.

Happy hacking!
Nikita

-- 
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/d/optout.


project.clj dependencies auto-update

2015-01-19 Thread Nikita Beloglazov
TL;DR if you have clojure project on github you can setup Hatnik 
http://hatnik.com/ to update dependencies by pull request once new 
versions are available

Hatnik is a project we started at ClojureCup. It allows you to subscribe to 
any libraries and perform certain actions once new versions are available. 
Recently we've added build file support meaning that now you can specify 
github repo or URL to project.clj and we will extract libraries from it. 
How to setup:

   1. Go to http://hatnik.com and login.
   2. Click Add project.
   3. Enter project name (any text you want, this is not github repo name).
   4. Enter build file, it can be either user/repo or full URL. If you 
   specify user/repo, we assume there is a project.clj file in root directory.
   5. Select action type. By default it is Email: you'll get email 
   notifications once new version of a dependency has been released. You might 
   want to switch to pull request. 
   6. Click Create. It may take some time to process your project.clj 
   file. After it is done you should see all dependencies displayed along with 
   their latest versions.
   7. Forget about Hatnik until a dependency has been updated. Then you'll 
   see pull request waiting for your approval.

Hatnik is especially nice when you have tests and CI integrated with 
github. This way you can see whether pull request breaks your project or 
not almost immediately without any efforts and merge it if everything is 
ok! Note: currently Hatnik doesn't open initial pull request that updates 
all deps to latest versions. It will open pull request next time a 
dependency is released. To perform this initial update you can use 
lein-ancient https://github.com/xsc/lein-ancient plugin or don't do 
anything and let Hatnik update deps as they're released. 
Hatnik is an open source project and you can find it on (surprise, 
surprise) github: https://github.com/nbeloglazov/hatnik Idea is similar to 
Artifact 
Listener https://www.artifact-listener.org/, VersionEye 
https://www.versioneye.com/, Jarkeeper https://jarkeeper.com/, but 
Hatnik can not only notify you about deps changes but can also help you to 
update them. 

If you find bugs or have some ideas how to impove Hatnik, please create an 
issue on github. Future plans are to support more build file formats 
(pom.xml, build.sbt, Gemfile and others), support libraries from other 
languages (ruby, js, python), improve UI. If you're interested in helping 
with development, please send me a short email or open issue with your idea 
so we can discuss it.

Thanks,
Nikita

-- 
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/d/optout.


Re: ANN: ClojureScript 0.0-2496, cljs.test - a clojure.test port

2014-12-17 Thread Nikita Beloglazov
Does cljs.test support asynchronous tests? What are benefits of cljs.test over 
clojurescript.test (https://github.com/cemerick/clojurescript.test)? 
Clojurescript.test also a port of clojure.test but has additional API for 
writing asynchronous tests.  

On Wednesday, December 17, 2014 2:39:22 PM UTC-8, Shaun LeBron wrote:
 really exciting stuff, thanks a lot
 
 On Wednesday, December 17, 2014 3:54:09 PM UTC-6, David Nolen wrote:
  ClojureScript, the Clojure compiler that emits JavaScript source code.
  
  README and source code: https://github.com/clojure/clojurescript
  
  New release version: 0.0-2496
  
  Leiningen dependency information:
  
  [org.clojure/clojurescript 0.0-2496]
  
  The big change in this release is a port of the clojure.test namespace
  - cljs.test.
  It is largely compatible with clojure.test and implements enough
  functionality such
  that we could port all of the existing tests to it. It's also featureful 
  enough
  to support a ClojureScript port of test.check that is underway.
  cljs.test is compatible
  with all of the optimization settings provided by the compiler including 
  :none.
  
  Still cljs.test may not satisfy all the patterns that people have come to 
  expect
  from clojure.test so feedback (and enhancement/fix patches) is very welcome.
  
  On the way we implemented changes to the compiler in order to make
  custom testing
  frameworks simpler to implement - this includes compiler support for
  :test metadata as well
  as introducing static vars.
  
  ClojureScript does not have vars, however there are var patterns that
  are largely
  static in nature and useful for metaprogramming and REPL interactions. 
  Towards
  this end we've implemented the `var` special form and introduced very 
  restricted
  functionality - metadata is the primary use case.
  
  (defn foo [])
  (meta #'foo) ;; will return the expected metadata
  
  cljs.test is implemented on top of this functionality as well as a new 
  namespace
  cljs.analyzer.api which I think macro writers will find quite useful.
  
  Also there's a doc macro now in the cljs.repl namespace that works as 
  expected.
  Patches welcome to bring all the useful bits of clojure.repl into cljs.repl.
  
  ## 0.0-2496
  
  ### Enhancements
  * cljs.test added, mirrors clojure.test
  * New cljs.analyzer.api namespace for easier access to analysis info from 
  macros
  * New cljs.analyzer.api namespace for easier access to analysis info from 
  macros
  * Support :test metadata on vars
  * Support static vars
  * cljs.source-map for client side source mapping
  * expose ClojureScript :warnings build option
  * CLJS-909: Add stable api for consumers of compiler data.
  
  ### Changes
  * convert all ClojureScript tests to cljs.test
  * add volatile! from Clojure 1.7
  * stateful transducers use volatile!
  * added `js-debugger` macro, compiles to debugger;
  * CLJS-892: Improve performance of compare-symbols/compare-keywords
  * CLJS-696: remove arguments usage from defrecord constructor
  * unroll `partial`, copy  pasted from Clojure core.clj
  * optimize clojure.string/join
  
  ### Fixes
  * fix `cljs.nodejs/enable-util-print!`, incorrectly monkey patched
  `cjls.core/string-print` instead of setting `cljs.core/*print-fn*`
  * cljs.reader bug, '/ incorrectly read
  * avoid emitting the same goog.require

-- 
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/d/optout.


[ANN] Quil 2.2.2 Release

2014-09-08 Thread Nikita Beloglazov
Happy to announce release of Quil 2.2.2. It is available on clojars:
https://clojars.org/quil

Here is the list of changes:

   - Processing.js is shipped in a jar to make it possible to include it
   using :preamble option to cljsbuild configuration.
   - Support available-fonts, load-pixels and pixels functions in cljs
   version.
   - Fix bug that prevented from using Quil cljs on headless servers.
   - Fix bugs that prevented Quil from automatically adding canvas to a
   page if the page is empty.
   - Documentation fixes.

Many thanks to contributors.

Happy hacking!
Nikita

-- 
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/d/optout.


[ANN] Quil 2.2.0: ClojureScript!

2014-07-14 Thread Nikita Beloglazov
Happy to announce release of Quil 2.2.0.
It is available on clojars: https://clojars.org/quil

*ClojureScript*
The main feature in this release is long-awaited support of Quil on
ClojureScript! Many thanks to Maksim Karandashov https://github.com/norgat,
who has been working on it as part of Google Summer of Code project. He did
a great job!

In order to quick-start with Quil on ClojureScript run:
lein new quil-cljs my-sketch

It will create a ClojureScript project with simple Quil sketch. Simply lein
compile it and open web/index.html page. That's all!

For more info check wiki article:
https://github.com/quil/quil/wiki/ClojureScript

It is first version of Quil on ClojureScript version so be ready to meet
bugs. Feedback is very welcome and will be very useful. If you find some
info which is incorrect/missing from wiki article - feel free to file an
issue or fix it yourself.

*Middleware*
Aside from ClojureScript support, two middleware were added in this
releases:

   - Navigation 3D - enables shooter-like navigation in 3D space. Available
   both for clj and cljs sketches. Check wiki article for more details:
   https://github.com/quil/quil/wiki/Navigation-3D

   - Pause On Error - pauses sketch if an exception was thrown from one of
   handlers. You can fix broken handler and then resume sketch by clicking any
   button. Idea was shamelessly copied from inkwell
   https://github.com/solita/inkwell, thanks Timo
   https://github.com/noidi! Available only for clj sketches.

*Future plans*
Maksim is going to continue working on ClojureScript support: fix bugs,
adding tests, polish documentation. Other than that, we're going to work on
improving website (http://quil.info) to include examples, probably add some
tutorials, implement cljs sketch sharing capability.

Happy Hacking!

Nikita Beloglazov

-- 
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/d/optout.


[ANN] Quil 2.1.0 released

2014-06-13 Thread Nikita Beloglazov
Friday the 13th and a full moon is ideal time for a release!

Happy to announce release of Quil 2.1.0. It is available on clojars:
https://clojars.org/quil

Here is the list of changes:

   - Middleware https://github.com/quil/quil/wiki/Middleware support.
   - Functional mode
   https://github.com/quil/quil/wiki/Functional-mode-%28fun-mode%29
   support.
   - Updated to Processing 2.2.1.
   - New methods: resize http://quil.info/image.html#resize and state-atom
   http://quil.info/state.html#state-atom.
   - :no-safe-draw feature renamed to :no-safe-fns.
   - Fixed NPE when exiting :p2d sketch using esc key. #110
   https://github.com/quil/quil/issues/110.
   - Wrap all user-provided function to safe wrappers. #106
   https://github.com/quil/quil/issues/106.

Most interesting changes are middleware
https://github.com/quil/quil/wiki/Middleware and functional mode
https://github.com/quil/quil/wiki/Functional-mode-%28fun-mode%29. Take a
look at them.

Thanks Maksim Karandashov for contributing and help with release testing.

Future plans:

   - Quil on ClojureScript - GSoC project which Maksim is working on.
   - More cool middleware. There some ideas on middleware wiki page, feel
   free to grab and implement them. Would be happy to get more
   ideas/implementations.
   - Work on http://quil.info to make it more than simple API site.

Your feedback is welcome.

Happy hacking!


Nikita Beloglazov

-- 
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/d/optout.


Clojure and clojurescript deps in libraries

2014-06-07 Thread Nikita Beloglazov
Hi

I have a question about best practice for development clojure/clojurescript
libraries.
Usually you can see following in project.clj in some library:

:dependencies [[org.clojure/clojure 1.5.1]
   [org.clojure/clojurescript 0.0-2197]]

Why not to put clojure and clojurescript deps under :dev profile?  All
clojure and clojurescript projects explicitly specify versions of clojure
ans clojurescript in their project.clj so I find it reduntant and
potentially conflicting to inherit them from library. So why put it library
project.clj in the first place?

So I would suggest to use :dev profile for this:

:profiles {:dev {:dependencies [[org.clojure/clojure 1.5.1]
[org.clojure/clojurescript 0.0-2197]]}}}

Using dev profile means that you have clojure and clojurescript for
development but when you release library - the library doesn't depend on
them and users get just code without infrastructure deps. I see following
pros with this approach:

   - No potential conflicts between library and project deps
   - Reduces confusion like ah, library depends on clojure 1.6.0, that
   means it doesn't work with 1.5.1.

I can't think of cons of this approach.

I'd be happy to hear other people opinions on that question.


Thanks,

Nikita

-- 
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/d/optout.


[ANN] Quil 2.0.0 released

2014-05-18 Thread Nikita Beloglazov
Happy to announce release of Quil 2.0.0!

To use Quil 2.0.0 update project.clj to following:

:dependencies [...
   [quil 2.0.0]]


Major change is that Quil now uses latest Processing 2.2.0. Check release
notes https://github.com/quil/quil/blob/master/RELEASE-NOTES.md for list
of all other changes. Github repo https://github.com/quil/quil.

Thanks everyone who helped with development of 2.0.0. Special thanks to
Maksim Karandashov who helped a lot with adding support of Processing
present mode and other features.

Future plans:

   - Maksim is working on Quil on ClojureScript project as part of Google
   Summer of Code program. You'll be able to run Quil sketches in browser by
   the end of this summer!
   - Support more functional-style sketches.

Happy hacking!

Nikita

-- 
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/d/optout.


Re: Quil for ClojureScript

2014-03-12 Thread Nikita Beloglazov
Hi Divyansh

You're welcome to submit a proposal for Quil in Clojurescript project. 
But please bear in mind that there are several students who're applying for 
the project so it may be wise to submit several applications for different 
projects.

Thank you,
Nikita

On Tuesday, March 11, 2014 12:26:18 PM UTC, Divyansh Prakash wrote:

 Hello!

 I am a Java developer, and the author of 
 3Coffeehttps://github.com/divs1210/3Coffee, 
 a 2D Game Engine (with custom inbuilt physics) that I wrote some 2 years 
 back.
 I stumbled across Clojure while trying to solve one of the *many* 
 threading issues I seemed to have with swing.

 I have been Lisping ever since. Check 
 thishttp://pizzaforthought.blogspot.in/2014/02/on-art-of-programming.htmlout.

 The point is: I like designing high-level APIs, and have a fairly good 
 understanding of Clojure (and working on it). I have worked with 
 graphics-processing before, and would like to work on the ClojureScript 
 port for Quil as a project for GSoC 2014.

 I have been busy with college all this while, but I'll start working on it 
 ASAP.
 Will keep you posted.


-- 
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/d/optout.


Re: More functional Quil

2014-03-10 Thread Nikita Beloglazov
Lee,

I think question about managing/updating state in quil pop ups pretty
frequently and many people expect quil to have built-in tools to do it in
functional style. And using atoms to update state may feel hacky. I think
this tools should exist and quil 2.0 is a good time to address the issue.
Yes, Pablo's and mine changes are cosmetic but still they will help to feel
functional nature of quil and I think it is a win.
As for translating Processing code to Quil - I think it's already not very
easy for people who has little experience with functional programming and
therefore I don't think these cosmetic changes will add much complexity.

The only issue I see, which is you mentioned, is having two similar but
still separate modes. It may create confusion for newcomers.

Though I will be glad to hear other opinions on the question and see if
people generally like the idea or would rather keep old good quil as it is.


Gary,
Thank you. It might be useful in future if we decide to implement similar
thing.


Thank you,
Nikita


On Mon, Mar 10, 2014 at 4:27 AM, Gary Trakhman gary.trakh...@gmail.comwrote:

 FWIW, I've got an example of a decoupled update/draw loop here:
 https://github.com/gtrak/quilltest/blob/master/src/quilltest/balls.clj


 On Sun, Mar 9, 2014 at 10:16 PM, Lee Spector lspec...@hampshire.eduwrote:


 FWIW I'm not crazy about these suggestions because they seem to me to be
 mostly cosmetic, and actually negative if they end up leading to multiple
 incompatible modes of operation. The Processing model seems to me to be
 intrinsically imperative, and it's also well-known by lots of people and
 easy to understand. The current Quil scheme, which provides fairly direct
 access to Processing's existing model from Clojure, still allows us to
 write functional-style code for all of the interesting stuff that we do
 within/between calls to the imperative Processing calls. And it allows one
 to translate Processing ideas into Quil relatively easily. So I like it
 like it is :-).

  -Lee

 On Mar 9, 2014, at 8:29 PM, Nikita Beloglazov wrote:

  Hi Pablo
 
  You can find similar old thread on Quil github repo:
 https://github.com/quil/quil/pull/19 It may serve as good background
 what other people considered to make Quil more functional-style.
 
  I like your suggestion though I would split your :draw function to 2
 fns: an :update function, which only purpose is to update state and :draw
 which draws state and doesn't change the world at all. If this approach is
 implemented - other handler functions like :mouse-move, :key-pressed are
 also need to become update-like functions - they should take state as
 argument and return new state.
 
  The only problem is that it is not backward compatible at all. But
 probably we still can do it... We can add option :fun-mode? true (stands
 for functional-mode) which enables all these changes - :draw takes state as
 argument, new :update function is added for modifying state, all handlers
 behave like :update. This option is enabled per-sketch. It requires
 additional work on Quil internals, but I think it is doable. This option
 can be implemented in coming quil 2.0 and it would be great feature to have.
 
  One more thing we could do to make it more functional-like - pass
 changed values to handlers directly. Currently when :key-pressed handler
 is called - no argument is passed to the function and you need to use
 (key-code) or (raw-key) functions to identify which key was pressed. I
 think this parameters should be explicitly passed to the function.
 
  What do you think?
 
  Nikita

 --
 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/d/optout.


  --
 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/UQ3iPC6Oj9g/unsubscribe.
 To unsubscribe from this group and all its topics, send an email

Re: More functional Quil

2014-03-09 Thread Nikita Beloglazov
Hi Pablo

You can find similar old thread on Quil github repo: 
https://github.com/quil/quil/pull/19 It may serve as good background what 
other people considered to make Quil more functional-style.

I like your suggestion though I would split your :draw function to 2 fns: 
an :update function, which only purpose is to update state and :draw which 
draws state and doesn't change the world at all. If this approach is 
implemented - other handler functions like :mouse-move, :key-pressed are 
also need to become update-like functions - they should take state as 
argument and return new state.

The only problem is that it is not backward compatible at all. But probably 
we still can do it... We can add option :fun-mode? true (stands for 
functional-mode) which enables all these changes - :draw takes state as 
argument, new :update function is added for modifying state, all handlers 
behave like :update. This option is enabled per-sketch. It requires 
additional work on Quil internals, but I think it is doable. This option 
can be implemented in coming quil 2.0 and it would be great feature to 
have. 

One more thing we could do to make it more functional-like - pass changed 
values to handlers directly. Currently when :key-pressed handler is called 
- no argument is passed to the function and you need to use (key-code) or 
(raw-key) functions to identify which key was pressed. I think this 
parameters should be explicitly passed to the function.

What do you think?

Nikita

On Sunday, March 9, 2014 1:21:58 PM UTC, J. Pablo Fernández wrote:



 On Sunday, March 9, 2014 1:02:52 PM UTC, Laurent PETIT wrote:

 Hello, 

 To be honest I don't see any fundamental difference between your first 
 attempt and the improvement: both share the fact that the mutation of the 
 state happens within the draw function. So in both cases, you have a 
 temporal coupling between updating the state of the app and rendering a new 
 view of the app's state.


 Yes, what's happening in both cases is very similar, but the function draw 
 in the functional style, in my opinion, is easier to read and maybe it's 
 also easier to test.
  

 I would suggest that you don't swap! at all within draw, just deref and 
 render the result of the dereffing.

 And, in another thread, at potentially a totally different pace than the 
 redrawing's pace, update the application's state accordingly to business 
 rules / constraints.

 Schematically, something like this: 

 (def app-state (atom (init-state)))

 (defn draw [...]
   (let [app-snapshot (deref app-state)]
   ... call quil primitives to render the application state snapshot 
 ...))

 (future
   ... logic which updates the app-state atom depending on business rules 
 / constraints, in a separate thread ...)


 I never worked with future, this is exciting, but I have some questions. 
 Do you mean that future is completely separate from draw? I'm just getting 
 started, but draw is not only a function to draw, but as a side effect is 
 the clock of the app, as it's called according to the set frames per second 
 and you normally *take a step* en each draw. Would draw create these 
 futures for the next draw?


-- 
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/d/optout.


Re: GSoC 2014: We need ideas and mentors

2014-02-07 Thread Nikita Beloglazov
Hi 

I don't have editing rights for wiki so I post project idea here:
*Quil on ClojureScript**Brief explanation: *Quilhttp://github.com/quil/quilis 
a drawing and animation library for clojure. It is basically wrapper 
over Processing http://processing.org. Currently Quil works only on 
vanilla clojure (JVM based). It would be cool to have it also on 
ClojureScript. Processing already have javascript version: 
Processing.jshttp://processingjs.org, 
so it can be used for our goals.*Expected results: *quil clojurescript 
library capable of running regular quil sketches, documentation how to use 
it in clojurescript project.*Knowledge prerequisites: *familiarity with 
clojurescript, javascript*Skill level: *medium*Mentor: *Nikita Beloglazov 
(nikelandj...@gmail.com)

Thank you,
Nikita

On Wednesday, February 5, 2014 6:19:55 PM UTC, Daniel Solano Gómez wrote:

 Hello, all, 

 It's time once again to prepare our application for Google Summer of 
 Code, a program where Google pays students from around the world to work 
 on open source projects.  Clojure has successfully participated in the 
 program for two years now, and I would love to make it a third.  GSoC 
 has helped projects like Typed Clojure, Clojure in Clojure, Clojure 
 on Android, core.matrix, and ClojureScript. 

 In order to have a strong application, we need you to help populate our 
 project ideas page [1].  You can also review the ideas for 2012 [2] and 
 2013 [3] to help you come up with new ideas.  Having a great ideas page 
 is key to a successful application, and having many members from the 
 community participate as potential mentors will be a big boost.  At this 
 point, you are not committing to anything—we just need your ideas. 

 If you don't have edit rights to the wiki and don't want to sign up for 
 an account, just post to the mailing list using '[GSoC Idea]' in the 
 subject line, and I'll add it for you. 

 Lastly, if you would like to review the answers to the organization 
 application [4], I would appreciate the input. 

 The application deadline the 14th of February. 

 Thank you for time and ideas. 

 Sincerely, 

 Daniel 


 [1]: http://dev.clojure.org/display/community/Project+Ideas 
 [2]: http://dev.clojure.org/display/community/Google+Summer+of+Code+2012 
 [3]: http://dev.clojure.org/display/community/Project+Ideas+2013 
 [4]: 
 http://dev.clojure.org/display/community/Mentoring+Organization+Application 


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


[ANN] Interactive tasks

2013-01-28 Thread Nikita Beloglazov
Hello

I've created a set of tasks for practising clojure. Here is repo: 
https://github.com/nbeloglazov/clojure-interactive-tasks
Key feature is interactivity: tasks  are visualized and user can see how 
solution works. Some tasks require knowledge of math or algorithms. Goal is 
the same as in 4clojure: help to learn and practise clojure. But there are 
some differences. 4clojure checks solutions by running tests while 
interactive tasks don't. User checks solution manually by running, no 
automatic check. 

Each task is a lein project. Task description usually placed in work.clj 
file and user solves task in same file. There are 7 tasks now. I used this 
tasks along with 4clojure tasks when taught small clojure class. It went 
pretty well and students said they liked homeworks that consisted of 
interactive tasks and 4clojure. 

Check the repo for screenshot examples. If you have ideas for new tasks 
please create an issue in the repo.

Thank you,
Nikita Beloglazov

-- 
-- 
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, send email to 
clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Unseemingly Eager Clojure Apprentice Seeking FizzBuzz Feeback

2012-12-29 Thread Nikita Beloglazov
Hi

I'd change your fizzy function so it returns a string instead of printing 
it. This way it will be pure function and more functional-like. In doseq 
you'll need (printlng (fuzzy x)) instead of 
(fuzzy x).

Nikita Beloglazov
On Saturday, December 29, 2012 3:35:38 PM UTC+3, Sean Chalmers wrote:

 Greetings all!

 I'm just starting out in the so far wonderful world of Clojure and to help 
 me get started I had a crack at one of my favourites, the FizzBuzz program. 
 For anyone that isn't familiar with FizzBuzz, it is designed to count from 
 1 to N and take the following actions when certain conditions are met:

- When the remainder of i divided by 3 is 0 print Fizz
- When the remainder of i divided by 5 is 0 print Buzz
- When both the former are true of i print FizzBuzz

 I crafted the following as a solution and I would really appreciate some 
 more experienced Clojurians casting their eye over it and letting me know 
 if what I've done is in the style and spirit of Clojure. Also this is my 
 first functional language so any feedback on that would be awesome too. :)

 I'm aware it's only a tnsy piece of code so not terribly 
 indicative of the hilarity that might ensue on a larger project but all the 
 same. Enough of my blathering here is the meaty bit:

 (defn zero-remainder? [x y]
   (zero? (rem x y)))

 (defn fizzy [x]
   (let [fizz (zero-remainder? x 3) buzz (zero-remainder? x 5)]
 (if (and fizz buzz)
   (println FizzBuzz:  x)
   (if buzz
 (println Buzz:  x)
 (if fizz
   (println Fizz:  x))

 (doseq [x (range 1 25)]
   (fizzy x))


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

Re: Clojure mug templates

2012-12-29 Thread Nikita Beloglazov
Thank you, John. I've fixed this.

Nikita

On Sat, Dec 29, 2012 at 8:21 PM, John Gabriele jmg3...@gmail.com wrote:

 On Saturday, December 29, 2012 8:54:44 AM UTC-5, Nikita Beloglazov wrote:

 Hi

 I taught small clojure class at my university this semester. At the end
 of the class I printed clojure mugs for my students with their names.
 Here I want to share small javascript/html page I used to generate
 templates for mugs. I hope someone find it useful.

 Page:
 http://nbeloglazov.github.com/**clojure-mug-template/http://nbeloglazov.github.com/clojure-mug-template/

 GitHub repo:
 https://github.com/**nbeloglazov/clojure-mug-**template/https://github.com/nbeloglazov/clojure-mug-template/


 Neat. Though, what is `slice`?

 Oh, and I don't see `comp` in there!

 Also, maybe replace noir with lib-noir now.

 ---John

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


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

Method overloading by the arity in proxy

2012-10-30 Thread Nikita Beloglazov
Hi. I have a java class that has 2 methods with same but different arities 
(one take no arguments, other takes 1 argument). I create a proxy that 
overrides both this methods. The problem is that if no-arg method is called 
from this java class - base implementation is called instead of proxie's. 
Here is an example: https://gist.github.com/3978729. But if I call no-arg 
method directly on obj - correct proxy method is invoked. I can't 
understand this behavior.

Thank you,
Nikita Beloglazov

-- 
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: Method overloading by the arity in proxy

2012-10-30 Thread Nikita Beloglazov
Thank you, Meikel. Seem I'll need to move to gen-class instead :(

Nikita

On Tuesday, October 30, 2012 12:41:41 PM UTC+3, Meikel Brandmeyer (kotarak) 
wrote:

 Hi,

 Am Dienstag, 30. Oktober 2012 08:14:22 UTC+1 schrieb Nikita Beloglazov:

 Hi. I have a java class that has 2 methods with same but different 
 arities (one take no arguments, other takes 1 argument). I create a proxy 
 that overrides both this methods. The problem is that if no-arg method is 
 called from this java class - base implementation is called instead of 
 proxie's. Here is an example: https://gist.github.com/3978729. But if I 
 call no-arg method directly on obj - correct proxy method is invoked. I 
 can't understand this behavior.


 proxy-super temporarily removes the method from the proxy map. So 
 recursive calls see directly the parent method.

 Kind regards
 Meikel

 Shameless self-promotion: 
 http://kotka.de/blog/2010/03/proxy_gen-class_little_brother.html 


-- 
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: Ideas for interactive tasks

2012-09-12 Thread Nikita Beloglazov
Zmitro: I'll definitely use 4clojure in teaching, but I'm looking for more
interactive tasks so I can use graphics/sound/charts/something else to
visualize them.

Murtaza: It's a great idea, but I'm experienced enough to take such task :)

Thank you,
Nikita

On Wed, Sep 12, 2012 at 8:43 AM, Murtaza Husain 
murtaza.hus...@sevenolives.com wrote:


 Thinking aloud, clojure could be used to create a DSL using which the
 students can experiment with concepts from different sciences, and see the
 results / effects in a graphical manner !!


 On Wednesday, September 12, 2012 11:03:04 AM UTC+5:30, Murtaza Husain
 wrote:


 This is really interesting. I am wondering if the idea could be broadened
 to not just teach CS, but also maths, physics and chemistry.

 A curriculum in which programming is used as a tool to explore the
 different sciences. An integrated curriculum to teach the different
 sciences.

 Please keep us posted on your progress.

 On Tuesday, September 11, 2012 6:00:43 PM UTC+5:30, Zmitro Lapcjonak
 wrote:


 On Aug 9, 6:21 pm, Nikita Beloglazov nikelandj...@gmail.com wrote:
  I'm going to organize little clojure course at my university this
 year. For
  this I want to implement set of tasks that hopefully will help to
 practise
  clojure.

 Some tasks you may find at 4clojure:
 https://www.4clojure.com/**problems https://www.4clojure.com/problems
 Sort by topic and select games, graph, data-analysis

 Project Euler has some interesting problems that you
 may use to teach Clojure and train math theory also.


  Thank you,

 Thank you and good luck!

 --
 Zmitro Lapcionak

  --
 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: Ideas for interactive tasks

2012-08-15 Thread Nikita Beloglazov

 It's really great that you are going to teach Clojure at BSU.

 I have no clue about teaching, but my impression is that back in my days,
 we didn't learn much about how to write good code.

I have no experience either, but I think it's not appropriate that CS
students know nothing about FP.


 Maybe things were different in 'informatics', but in 'applied
 mathematics', for instance, we only had exposure to imperative programming.

No, things are still the same, we study java, c++, assembler.

I think, your course could get students familiar with the concepts and
 benefits of FP (immutability, referential transparency, etc.). Then they
 could learn more specific things like persistent data structures,
 multimethods, macros, agents, etc.. I would probably try to emphasize the
 advantages of certain features of Clojure and FP in general, when it is
 appropriate to use them and how.

Yes, it is the main goal of the course. I'm only afraid I don't understand
them completely myself. I don't have real-life projects in clojure, just a
few pet-projects. Here are the topics I want to cover:
1. Introduction, install and setup clojure, lein.
2. Basics (def, defn, let, if, numbers, strings)
3. Collections (immutability, types of collections, functions for
manipulating collections)
4. Concurrency (atoms, refs, agents)
5. Study implementation of some persistent datastructure (e.g.
PersistentVector).
6. Macros (I used it very few times, so don't have examples to show).
7. Multimethods (same situation as with macros)
8. Datatatypes and protocols (even worse)
9. Little of Lambda Calculus (implement numbers, true/false, pairs,
recursion).
10. Play with some clojure projects (e.g. overtone).
I'll have about 3 months, so it's approximately 1 week (1 lesson) for a
topic. I want students to read next lesson topic before the lesson and
first half of the lesson discuss it and the second to solve tasks (and
solve tasks during a week). I'm not sure it will work but I hope :)

As for the interactive tasks, I think, it's a good idea, as they are fun.
 My only note so far is that they seem to require quite some effort
 unrelated to learning Clojure, but it may be what you intended (would be
 nice seing your course program).
 For instance, in 'artillery' task, the time it took to code up the
 solution was infinitesimal, compared to the time I spent building the model
 and recalling how to solve trigonometric and quadratic equations :). But
 seing the plain fall was rewarding...

Yes, it is harder than I expected, but we also a math faculty so we must be
able to solve such tasks :)


One task I remember form my courses was to program a trolley that moves
 parts between the machines of a production line (Each machine has an input
 and output queue with limited capacities, and a distinct processing time).
 This can also be extended for concurrency task, if you introduce two
 trolleys, etc.

Could you explain how to model it in clojure? Or how to start modelling.


 Another thought about concurrency - let them program the 'dining
 philosophers'.
 In addition, the idea of writing game bots can be exploited further: e.g.
 what about a tetris bot?

Yes, why not? :) It will be pretty advanced task (from algorithmical point
of view).
Need to invent more games :)


 I'm very excited about your intent to teach Clojure at BSU. I would be
 glad to stay in touch for further discussions.

 Daniil

 Ideally I want students to develop some projects in clojure (game or web
project or something else). But I don't know whether they like this idea.

Thank you for you reply!

Nikita



 On Monday, August 13, 2012 9:17:26 PM UTC+2, Nikita Beloglazov wrote:

 Daniil, yes it is
 Do you have some suggestions about tasks or teaching at the BSU in
 generally? :)

 Nikita


 On Mon, Aug 13, 2012 at 9:00 PM, dmirylenka daniilm...@gmail.com wrote:

 Wow, too bad I already graduated :)

 ФПМИ?


 On Thursday, August 9, 2012 5:28:54 PM UTC+2, Nikita Beloglazov wrote:

 Thank you, Jim. This is Belarusian State University.

 On Thu, Aug 9, 2012 at 6:23 PM, Jim - FooBar(); jimpi...@gmail.comwrote:

 On 09/08/12 16:21, Nikita Beloglazov wrote:

 I'm going to organize little clojure course at my university this
 year.


 this is amazing! seriously, bravo! what university is this?

 Jim


 --
 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...@**googlegrou**ps.com

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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

Re: Ideas for interactive tasks

2012-08-13 Thread Nikita Beloglazov
Thanks for idea, Igor. Seems like some kind of simulation (looking at your
example and clojure ants demo) can be a good example of concurrency.

Thank you,
Nikita

On Sun, Aug 12, 2012 at 2:01 PM, Igor Kupczyński puszc...@gmail.com wrote:

 Hi,

 For a java course at my university students had to write a railway
 simulator - the idea was more or less to write randomly generate a map with
 railways and regular roads. Some of the tracks where double (i.e. trains
 can go both directions at the same time) and the other just a single track
 (one train, one direction at a time). In the the single tracks there were
 special bays for trains to wait while a train in the opposite direction is
 running. There were passenger trains and cargo trains, but the former had a
 priority over the latter (when single tracks were considered). There were
 cars on the regular roads (all bidirectional and running at the same
 speed), the only challenge for cars was to stop when a road crossed a
 railway and there was a train running on that railway. The idea was of
 course not cause any collision. The graphics had to pretty simple, i.e. 2d
 bird perspective, rectangles representing trains and squares representing
 cars.

 Of course this was quite a big end-of-semester assignment. Maybe it will
 give you some ideas.

 Thanks,
 Igor

 On Thursday, 9 August 2012 17:21:45 UTC+2, Nikita Beloglazov wrote:

 Hello
 I'm going to organize little clojure course at my university this year.
 For this I want to implement set of tasks that hopefully will help to
 practise clojure.
 Tasks will be animated so students can see how their solutions work. E.g.
 one of the tasks is to hit plane by missile: there is a plane that flies
 from left to the right with fixed speed. Player launches missile to hit the
 plane. Task is to write a function that takes coordinates of plane and
 player and returns angle for launching missile. Plane's and missile's
 speeds are constant and known. This task requires math and basic clojure
 knowledge (only perform math operations, use let, if, Math/* functions).
 Another example is to implement a bot for snake. Bot is implemented as a
 function that takes snakes position (sequence of cells, each cell is vector
 of 2 values) and apple position (vector of 2 values). Function must return
 what direction to move. This task requires using of clojure seq functions.
 Can somebody propose ideas for this kind of tasks? I'm particularly
 interested in tasks that require different fields of clojure, e.g. I don't
 know what to implement for learning atoms, refs and agends.

 Examples of tasks (artillery and snake) can be found here:
 https://github.com/**nbeloglazov/clojure-**interactive-taskshttps://github.com/nbeloglazov/clojure-interactive-tasks.
 I use quil https://github.com/quil/quilfor animation. Animation is
 primitive in the tasks (I'm not particularly good at it).

 Thank you,
 Nikita Beloglazov

  --
 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: Ideas for interactive tasks

2012-08-13 Thread Nikita Beloglazov
Daniil, yes it is
Do you have some suggestions about tasks or teaching at the BSU in
generally? :)

Nikita


On Mon, Aug 13, 2012 at 9:00 PM, dmirylenka daniilmirile...@gmail.comwrote:

 Wow, too bad I already graduated :)

 ФПМИ?


 On Thursday, August 9, 2012 5:28:54 PM UTC+2, Nikita Beloglazov wrote:

 Thank you, Jim. This is Belarusian State University.

 On Thu, Aug 9, 2012 at 6:23 PM, Jim - FooBar(); jimpi...@gmail.comwrote:

 On 09/08/12 16:21, Nikita Beloglazov wrote:

 I'm going to organize little clojure course at my university this year.


 this is amazing! seriously, bravo! what university is this?

 Jim


 --
 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...@**googlegrou**ps.com

 For more options, visit this group at
 http://groups.google.com/**group**/clojure?hl=enhttp://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

Ideas for interactive tasks

2012-08-09 Thread Nikita Beloglazov
Hello
I'm going to organize little clojure course at my university this year. For 
this I want to implement set of tasks that hopefully will help to practise 
clojure. 
Tasks will be animated so students can see how their solutions work. E.g. 
one of the tasks is to hit plane by missile: there is a plane that flies 
from left to the right with fixed speed. Player launches missile to hit the 
plane. Task is to write a function that takes coordinates of plane and 
player and returns angle for launching missile. Plane's and missile's 
speeds are constant and known. This task requires math and basic clojure 
knowledge (only perform math operations, use let, if, Math/* functions). 
Another example is to implement a bot for snake. Bot is implemented as a 
function that takes snakes position (sequence of cells, each cell is vector 
of 2 values) and apple position (vector of 2 values). Function must return 
what direction to move. This task requires using of clojure seq functions.
Can somebody propose ideas for this kind of tasks? I'm particularly 
interested in tasks that require different fields of clojure, e.g. I don't 
know what to implement for learning atoms, refs and agends. 

Examples of tasks (artillery and snake) can be found here: 
https://github.com/nbeloglazov/clojure-interactive-tasks. I use quil 
https://github.com/quil/quilfor animation. Animation is primitive in the 
tasks (I'm not particularly good at it).

Thank you,
Nikita Beloglazov

-- 
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: Ideas for interactive tasks

2012-08-09 Thread Nikita Beloglazov
Thank you, Jim. This is Belarusian State University.

On Thu, Aug 9, 2012 at 6:23 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:

 On 09/08/12 16:21, Nikita Beloglazov wrote:

 I'm going to organize little clojure course at my university this year.


 this is amazing! seriously, bravo! what university is this?

 Jim


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

2010-08-10 Thread Nikita Beloglazov
Hi, Tim
Can you describe you task?
Sets (and other collections) in clojure don't use generics, as I know. You
can add element to set and check if set contains element. Why do you need
MyType? To allow add only MyType elements in set?

On Tue, Aug 10, 2010 at 11:40 PM, Tim Daly d...@axiom-developer.org wrote:

 I have java code that reads:


 SetMyType s = new HashSet();

 I don't know how to write the parameter MyType in clojure
 where MyType is a Java class.

 Laurent PETIT wrote:

 2010/8/10 Tim Daly d...@axiom-developer.org mailto:
 d...@axiom-developer.org


How do I construct
 SetMyType s = new HashSet();
in clojure?


 Can you be more precise about the context of what you're trying to achieve
 ?


 'cause the naive answer to your question is

 (def s #{})
 or
 (let [s #{}] ...)

 but I think you have a usecase in mind I'm not clearling seeing yet from
 your question ...

 --
 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.comclojure%2bunsubscr...@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.comclojure%2bunsubscr...@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: How to construct SetMyType

2010-08-10 Thread Nikita Beloglazov

 If the JGraphT constructor takes say 2 args arg1 and arg2, you'll just
 write
 (let [graph (JGraphT. arg1 arg2)] ) and every side will be happy:
 clojure, and java.


And when you need to add vertex or edge you create it and add.
If you need to get edge (e.g. getEdge(...) method) you just call it with
appropriate vertexes and it will return edge. And you assume that it will
return object of the same type, you've added.



On Wed, Aug 11, 2010 at 12:25 AM, Laurent PETIT laurent.pe...@gmail.comwrote:

 2010/8/10 Tim Daly d...@axiom-developer.org

 This code uses the JGraphT graphing package which
 wants to create a graph where the types of the
 vertices and edges are generics, as in:

 JGraphTMyVertexType,MyEdgeType graph = 

 and I'm at a loss for how to instantiate a graph in clojure.


 Tim, Generics in java are there only for making the java compiler happy
 (err sorry, in order for the compiler to help you write more robust code ;-)
 ). They are lost (erased) at runtime, even in pure java.

 So you just don't need to care for generics when instanciating objects from
 clojure, even with java interoperability in mind.

 If the JGraphT constructor takes say 2 args arg1 and arg2, you'll just
 write
 (let [graph (JGraphT. arg1 arg2)] ) and every side will be happy:
 clojure, and java.




 Armando Blancas wrote:

 If you must use Java's HashSet, you can use it untyped:

 user= (deftype MyType [])
 user.MyType
 user= (def my-set (HashSet.))
 #'user/my-set
 user= (.add my-set (MyType.))
 true
 user= (.add my-set (java.util.Date.))
 true

 If you need to enforce the use of a type, use a checked set:

 user= (def checked (java.util.Collections/checkedSet my-set MyType))
 #'user/checked
 user= (.add checked (MyType.))
 true
 user= (.add checked (java.util.Date.))
 java.lang.ClassCastException: Attempt to insert class java.util.Date
 element
 into collection with element type class user.MyType (NO_SOURCE_FILE:0)

 On Aug 10, 1:40 pm, Tim Daly d...@axiom-developer.org wrote:


 I have java code that reads:

 SetMyType s = new HashSet();

 I don't know how to write the parameter MyType in clojure
 where MyType is a Java class.



 Laurent PETIT wrote:


 2010/8/10 Tim Daly d...@axiom-developer.org
 mailto:d...@axiom-developer.org
  How do I construct
 SetMyType s = new HashSet();
in clojure?
  Can you be more precise about the context of what you're trying to
 achieve ?
  'cause the naive answer to your question is
  (def s #{})
 or
 (let [s #{}] ...)
  but I think you have a usecase in mind I'm not clearling seeing
 yet
 from your question ...
  --
 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.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en- Hide quoted text -


 - Show quoted text -






 --
 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.comclojure%2bunsubscr...@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.comclojure%2bunsubscr...@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: thread running throwing error java.lang.Thread cannot be cast to clojure.lang.IFn

2010-08-06 Thread Nikita Beloglazov
What do you mean close threads?
As I know threads aren't supposed to be closed. There is no mechanism to do
this. They are not connections or smth like that.

On Fri, Aug 6, 2010 at 3:46 PM, foop1 bsmd...@gmail.com wrote:

 thank you for the reply, is there any way to close this 4 threads
 after the job is done?

 On Aug 6, 8:34 am, Nikita Beloglazov nikelandj...@gmail.com wrote:
  Hi, foop
  Your error in this line:
  (r4t (on-thread (prnTime)))
  You pass to function r4t thread instead of functions. Because
  (on-thread (prnTime)) returns thread
  You must pass #(on-thread (prnTime)) instead
 
  Regards,
  Nikita Beloglazov
 
 
 
  On Fri, Aug 6, 2010 at 3:13 PM, foop1 bsmd...@gmail.com wrote:
   Hi,
 
   Iam trying to run a function in a thread assuming that threads are
   runnable, below is my program i want to print 4 time the current date
 
   (defn- on-thread [f]
(doto (Thread. #^Runnable f)
  (.start)))
 
   (defn prnTime [] (prn (System/currentTimeMillis)))
 
   (defn r4t [f]
(dotimes [n 4] (f)))
 
   (r4t (on-thread (prnTime)))
   iam getting this error what is wrong with this ?
   java.lang.Thread cannot be cast to clojure.lang.IFn
 
   Pls let me know what is wrong and how to make it run in 4 threads so
   that i can see 4 time the system print to the screen
 
   --
   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.comclojure%2bunsubscr...@googlegroups.com
 clojure%2bunsubscr...@googlegroups.comclojure%252bunsubscr...@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.comclojure%2bunsubscr...@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: (java.io BufferedReader FileReader) versus [clojure.contrib.duck-streams :only (read-lines)]

2010-08-06 Thread Nikita Beloglazov
Hi Dave,
There are really 2 functions, - and -
First -
Sometimes you need to perform several functions on after another. You can
write something like
(func1 (func2 (func3 value)))
But you also can write like:
(- value
  (func3)
  (func2)
  (func1))
It takes value, insert it into (func1) form as second element, so it will
become (func3 value), evaluates it. Result of evaluation insert into
(func2), evaluates it and etc.
- function inserts value as second element, e.g.  (form3 a b c) becomes
(form3 value a b c)
- function inserts value as last element, e.g. (form3 a b c)  becomes
(form3 a b c value)

(- (read-lines pdb-file)
   (map #(parse-line % chains))
   (apply concat)))
First it evaluates (read-lines pdb-file), let's name the result seq1
Then it evaluates (map #(parse-line % chains) seq1) and we get seq2
And finally it evaluates (apply concat seq2)

Regards,
Nikita Beloglazov

On Fri, Aug 6, 2010 at 7:26 PM, Dave david.dreisigme...@gmail.com wrote:

 Hi Nikita,

 Your function works!  Could you explain the - a bit?  Thanks, -
 Dave

 On Aug 5, 5:53 pm, Nikita Beloglazov nikelandj...@gmail.com wrote:
  See my variant of your application:
 https://gist.github.com/efdb66487e899446332f
  I don't know if it works, because I can't test :(
 
  My thoughts about your example
  You shouldn't think about this procedure as about procedure where you use
  loop, like in other imperative languages with mutable data. As I
 understand
  you tried something like:
 
  for every line in file do
  if line matches then
   convert line to coords
   add coords to global variable hold-coords
 end if
  end for
 
  But it's not the clojure way, I think clojure way is:
 
  get all lines as sequence
  convert every element of this sequence to vector of coords
  concat all vectors to one
 
  And in your exampledpa (def y  [5 6 7]) (let [x (into y [2 3 4]) y x ]
 y)
  [5 6 7 2 3 4]
  dpa y
  [5 6 7]
 
  When you use y in let, it introduce new local variable y, which hides
  global y
  It you want to use mutable data (I don't think it's good), you can use
 atoms
  - it's special mmm... mechanism for mutable data:
 
  user (def y (atom [1 2 3]))
  #'user/y
 
  user @y
  [1 2
  3]
 
  user (swap! y into [4 5 6])
  [1 2 3 4 5
  6]
 
  user @y
  [1 2 3 4 5
  6]
 
  Here you bind to variable y an atom with initial value - vector [1 2 3].
 To
  get value of atom you use @ before the variable name: @y
  To change value you call (swap! atom func x y z). First it calculates new
  value like this: (func @atom x y z), in our example it will calculate
 (into
  @y [4 5 6]). It returns vector [1 2 3 4 5 6], and this vector is set as
 new
  value of y.
 
  Regards,
  Nikita Beloglazov
 
 
 
  On Thu, Aug 5, 2010 at 11:49 PM, Dave david.dreisigme...@gmail.com
 wrote:
   Thanks for the extra parentheses catch.  I just noticed that while
   working on a different function (after hours of trying to figure it
   out).
 
   The program is reading in a pdb file line-by-line.  I only want the
   xyz-coordinates of carbon atoms, avoiding any repeats when the
   coordinate of an atom is uncertain.  Also, a protein may have multiple
   sub-units, and the chains parameter can pick out the desired sub-
   unit(s).  So I need to:
   1) make sure the line is long enough
   2) make sure I have an atom
   3) make sure it's not a repeated measurement
   4) make sure it's a C_{alpha} atom
   If the current pdb-file line matches those criteria, I'll then put its
   xyz-coordinates into the output matrix.
 
   I tried this using let:
 
   (defn process-dpa-file2
 This makes the matrix of CA coordinates from a pdb file.
[pdb-file chains]
(def hold-coords [])
(doseq [^String line (read-lines pdb-file)]
  ;; Make sure the file line is the correct length
  ;; We only want the atom entries
  ;; We don't want any repeated measurements for an atom
  ;; Is it a CA?
  ;; Are we using this chain?
  (if (and (= (.length line) 80)
   (= (str (.substring line 0 4) (.substring line 26 27)
   (.substring line 13 15)) ATOM CA)
   (substring? (.substring line 21 22) chains))
 ;; These are the CA coordinates
(let [coords (into hold-coords [ (Double. (.substring line 30
   37))
  (Double. (.substring line 38
 45))
  (Double. (.substring line 46
 53))])
   hold-coords coords]))
  (matrix hold-coords 3)))
 
   but the output gives:
 
   dpa (def my-mat (process-dpa-file2 /Users/daviddreisigmeyer/MyStuff/
   DPA_release_12-JUL-2010/1RD8.pdb A) )
   #'dpa/my-mat
   dpa my-mat
   nil
 
   A simpler example:
 
   dpa (def y  [5 6 7]) (let [x (into y [2 3 4]) y x ] y)
   [5 6 7 2 3 4]
   dpa y
   [5 6 7]
 
   So it seems that in process-dpa-file2 I have the coordinates of the
   1st carbon atom in hold-coords, and then the 2nd, the 3rd ... After
   finding the 3rd carbon, I'd want

Re: (java.io BufferedReader FileReader) versus [clojure.contrib.duck-streams :only (read-lines)]

2010-08-05 Thread Nikita Beloglazov
Hi, Dave
Why do you use 2 parenthesis before with-open in the first variant?
And, as I know, it's not good practice to use def inside functions. Use let
instead.
I also advice you to split your program to smaller functions.
Can you describe, what your program must do? Because don't understand :(

On Thu, Aug 5, 2010 at 9:28 PM, Dave david.dreisigme...@gmail.com wrote:

 Hi,

 I don't understand why this doesn't work:

 (ns dpa
  (:gen-class)
  (:use [incanter.core :only ( matrix )]
[clojure.core :only ( defn doseq line-seq println with-open )]
[clojure.contrib.string :only ( blank? substring? )]
  (:import (java.io BufferedReader FileReader)))

 (defn process-dpa-file
  This makes the matrix of CA coordinates from a pdb file.
  [pdb-file chains]
  (def hold-coords [])
  ((with-open [rdr (BufferedReader. (FileReader. pdb-file))]
  (doseq [^String line (line-seq rdr)]
;; Make sure the file line is the correct length
;; We only want the atom entries
;; We don't want any repeated measurements for an atom
;; Is it a CA?
;; Are we using this chain?
(if (and (= (.length line) 80)
 (= (str (.substring line 0 4) (.substring line 26 27)
 (.substring line 13 15)) ATOM CA)
 (substring? (.substring line 21 22) chains))
  ;; This are the CA coordinates
  (def hold-coords (into hold-coords [ (Double. (.substring line
 30 37))
   (Double. (.substring line 38 45))
   (Double. (.substring line 46 53))
 ] )
   (matrix hold-coords 3)))


 dpa (def my-mat (process-dpa-file /Users/daviddreisigmeyer/MyStuff/
 DPA_release_12-JUL-2010/1RD8.pdb A) )
 No message.
  [Thrown class java.lang.NullPointerException]

 Restarts:
  0: [QUIT] Quit to the SLIME top level

 Backtrace:
  0: dpa$process_dpa_file.invoke(NO_SOURCE_FILE:1)
  1: clojure.lang.AFn.applyToHelper(AFn.java:165)
  2: clojure.lang.AFn.applyTo(AFn.java:151)
  3: clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2901)
  4: clojure.lang.Compiler$DefExpr.eval(Compiler.java:361)
  5: clojure.lang.Compiler.eval(Compiler.java:5424)
  6: clojure.lang.Compiler.eval(Compiler.java:5386)
  7: clojure.core$eval.invoke(core.clj:2382)
  8: swank.commands.basic$eval_region.invoke(basic.clj:47)
  9: swank.commands.basic$eval_region.invoke(basic.clj:37)
  10: swank.commands.basic$eval799$listener_eval__800.invoke(basic.clj:
 71)
  11: clojure.lang.Var.invoke(Var.java:365)
  12: dpa$eval9236.invoke(NO_SOURCE_FILE)
  13: clojure.lang.Compiler.eval(Compiler.java:5419)
  14: clojure.lang.Compiler.eval(Compiler.java:5386)
  15: clojure.core$eval.invoke(core.clj:2382)
  16: swank.core$eval_in_emacs_package.invoke(core.clj:90)
  17: swank.core$eval_for_emacs.invoke(core.clj:237)
  18: clojure.lang.Var.invoke(Var.java:373)
  19: clojure.lang.AFn.applyToHelper(AFn.java:169)
  20: clojure.lang.Var.applyTo(Var.java:482)
  21: clojure.core$apply.invoke(core.clj:540)
  22: swank.core$eval_from_control.invoke(core.clj:97)
  23: swank.core$eval_loop.invoke(core.clj:102)
  24: swank.core$spawn_repl_thread$fn__484$fn__485.invoke(core.clj:307)
  25: clojure.lang.AFn.applyToHelper(AFn.java:159)
  26: clojure.lang.AFn.applyTo(AFn.java:151)
  27: clojure.core$apply.invoke(core.clj:540)
  28: swank.core$spawn_repl_thread$fn__484.doInvoke(core.clj:304)
  29: clojure.lang.RestFn.invoke(RestFn.java:398)
  30: clojure.lang.AFn.run(AFn.java:24)
  31: java.lang.Thread.run(Thread.java:637)



 But, this does work:

 (defn process-dpa-file
  This makes the matrix of CA coordinates from a pdb file.
  [pdb-file chains]
  (def hold-coords [])
  (doseq [^String line (read-lines pdb-file)]
;; Make sure the file line is the correct length
;; We only want the atom entries
;; We don't want any repeated measurements for an atom
;; Is it a CA?
;; Are we using this chain?
(if (and (= (.length line) 80)
 (= (str (.substring line 0 4) (.substring line 26 27)
 (.substring line 13 15)) ATOM CA)
 (substring? (.substring line 21 22) chains))
  ;; This are the CA coordinates
  (def hold-coords (into hold-coords [ (Double. (.substring line
 30 37))
   (Double. (.substring line 38 45))
   (Double. (.substring line 46 53))
 ] 
  (matrix hold-coords 3))

 dpa (def my-mat (process-dpa-file /Users/daviddreisigmeyer/MyStuff/
 DPA_release_12-JUL-2010/1RD8.pdb A) )
 #'dpa/my-mat


 I'd certainly appreciate any comments on the code in general.  I only
 have a Matlab/R/Fortran 95 background.

 Thanks,

 -Dave

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 

Re: (java.io BufferedReader FileReader) versus [clojure.contrib.duck-streams :only (read-lines)]

2010-08-05 Thread Nikita Beloglazov
See my variant of your application:
https://gist.github.com/efdb66487e899446332f
I don't know if it works, because I can't test :(

My thoughts about your example
You shouldn't think about this procedure as about procedure where you use
loop, like in other imperative languages with mutable data. As I understand
you tried something like:

for every line in file do
if line matches then
 convert line to coords
 add coords to global variable hold-coords
   end if
end for

But it's not the clojure way, I think clojure way is:

get all lines as sequence
convert every element of this sequence to vector of coords
concat all vectors to one


And in your example
dpa (def y  [5 6 7]) (let [x (into y [2 3 4]) y x ] y)
[5 6 7 2 3 4]
dpa y
[5 6 7]
When you use y in let, it introduce new local variable y, which hides
global y
It you want to use mutable data (I don't think it's good), you can use atoms
- it's special mmm... mechanism for mutable data:

user (def y (atom [1 2 3]))
#'user/y

user @y
[1 2
3]

user (swap! y into [4 5 6])
[1 2 3 4 5
6]

user @y
[1 2 3 4 5
6]


Here you bind to variable y an atom with initial value - vector [1 2 3]. To
get value of atom you use @ before the variable name: @y
To change value you call (swap! atom func x y z). First it calculates new
value like this: (func @atom x y z), in our example it will calculate (into
@y [4 5 6]). It returns vector [1 2 3 4 5 6], and this vector is set as new
value of y.

Regards,
Nikita Beloglazov


On Thu, Aug 5, 2010 at 11:49 PM, Dave david.dreisigme...@gmail.com wrote:

 Thanks for the extra parentheses catch.  I just noticed that while
 working on a different function (after hours of trying to figure it
 out).

 The program is reading in a pdb file line-by-line.  I only want the
 xyz-coordinates of carbon atoms, avoiding any repeats when the
 coordinate of an atom is uncertain.  Also, a protein may have multiple
 sub-units, and the chains parameter can pick out the desired sub-
 unit(s).  So I need to:
 1) make sure the line is long enough
 2) make sure I have an atom
 3) make sure it's not a repeated measurement
 4) make sure it's a C_{alpha} atom
 If the current pdb-file line matches those criteria, I'll then put its
 xyz-coordinates into the output matrix.

 I tried this using let:

 (defn process-dpa-file2
   This makes the matrix of CA coordinates from a pdb file.
  [pdb-file chains]
  (def hold-coords [])
  (doseq [^String line (read-lines pdb-file)]
;; Make sure the file line is the correct length
;; We only want the atom entries
;; We don't want any repeated measurements for an atom
;; Is it a CA?
;; Are we using this chain?
(if (and (= (.length line) 80)
 (= (str (.substring line 0 4) (.substring line 26 27)
 (.substring line 13 15)) ATOM CA)
 (substring? (.substring line 21 22) chains))
   ;; These are the CA coordinates
  (let [coords (into hold-coords [ (Double. (.substring line 30
 37))
(Double. (.substring line 38 45))
(Double. (.substring line 46 53))])
 hold-coords coords]))
(matrix hold-coords 3)))

 but the output gives:

 dpa (def my-mat (process-dpa-file2 /Users/daviddreisigmeyer/MyStuff/
 DPA_release_12-JUL-2010/1RD8.pdb A) )
 #'dpa/my-mat
 dpa my-mat
 nil

 A simpler example:

 dpa (def y  [5 6 7]) (let [x (into y [2 3 4]) y x ] y)
 [5 6 7 2 3 4]
 dpa y
 [5 6 7]

 So it seems that in process-dpa-file2 I have the coordinates of the
 1st carbon atom in hold-coords, and then the 2nd, the 3rd ... After
 finding the 3rd carbon, I'd want:

 hold-coords = [x1 y1 z1 x2 y2 z2 x3 y3 z3] (**)

 but instead I get

 hold-coords = [x3 y3 z3].  Any idea about how I could get (**)
 instead?  Thanks! -Dave

 On Aug 5, 2:46 pm, Nikita Beloglazov nikelandj...@gmail.com wrote:
  Hi, Dave
  Why do you use 2 parenthesis before with-open in the first variant?
  And, as I know, it's not good practice to use def inside functions. Use
 let
  instead.
  I also advice you to split your program to smaller functions.
  Can you describe, what your program must do? Because don't understand :(
 
 
 
  On Thu, Aug 5, 2010 at 9:28 PM, Dave david.dreisigme...@gmail.com
 wrote:
   Hi,
 
   I don't understand why this doesn't work:
 
   (ns dpa
(:gen-class)
(:use [incanter.core :only ( matrix )]
  [clojure.core :only ( defn doseq line-seq println with-open )]
  [clojure.contrib.string :only ( blank? substring? )]
(:import (java.io BufferedReader FileReader)))
 
   (defn process-dpa-file
This makes the matrix of CA coordinates from a pdb file.
[pdb-file chains]
(def hold-coords [])
((with-open [rdr (BufferedReader. (FileReader. pdb-file))]
(doseq [^String line (line-seq rdr)]
  ;; Make sure the file line is the correct length
  ;; We only want the atom entries
  ;; We don't want any repeated measurements for an atom
  ;; Is it a CA

Re: What is #_

2010-08-03 Thread Nikita Beloglazov
#_ comments the whole form, starting with parent just after #_ : #_(bla-bla
(bla-bla2 ... ) )
for example
(+  #_ (+
2 3 4 (* 1 2) )
  1 2)
Will return 3, because form with (+ 2 3 ... )  will be ignored by reader
So it's restricted by 1 line like ;

Regards
Nikita Beloglazov

On Tue, Aug 3, 2010 at 10:35 PM, Meikel Brandmeyer m...@kotka.de wrote:

 Hi,

 Am 03.08.2010 um 16:45 schrieb Yang Dong:

  I've read the src of core.clj of Clojure 1.1.0. Originally I thought
  the meaning of #_ is to comment the thing after it, sort of like `;'.
  But the in the src of core.clj in 1.2.0-RC1. The definition of reduce
  is overrided to use the internal-reduce function. The defn line, is
  preceded by `#_'. But in 1.1.0, it's not preceded by this reader
  macro. So, I'm confused...

 You are absolutely right. The #_ is kind of comment. And in fact the
 override with the internal reduce function is commented out (ie. it’s not
 active) in 1.2.

 Sincerely
 Meikel

 --
 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.comclojure%2bunsubscr...@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: What is #_

2010-08-03 Thread Nikita Beloglazov
Sorry, it's NOT restricted by 1 line, like ;
:)
Regards
Nikita Beloglazov

On Tue, Aug 3, 2010 at 10:54 PM, Nikita Beloglazov
nikelandj...@gmail.comwrote:

 #_ comments the whole form, starting with parent just after #_ : #_(bla-bla
 (bla-bla2 ... ) )
 for example
 (+  #_ (+
 2 3 4 (* 1 2) )
   1 2)
 Will return 3, because form with (+ 2 3 ... )  will be ignored by reader
 So it's restricted by 1 line like ;

 Regards
 Nikita Beloglazov


 On Tue, Aug 3, 2010 at 10:35 PM, Meikel Brandmeyer m...@kotka.de wrote:

 Hi,

 Am 03.08.2010 um 16:45 schrieb Yang Dong:

  I've read the src of core.clj of Clojure 1.1.0. Originally I thought
  the meaning of #_ is to comment the thing after it, sort of like `;'.
  But the in the src of core.clj in 1.2.0-RC1. The definition of reduce
  is overrided to use the internal-reduce function. The defn line, is
  preceded by `#_'. But in 1.1.0, it's not preceded by this reader
  macro. So, I'm confused...

 You are absolutely right. The #_ is kind of comment. And in fact the
 override with the internal reduce function is commented out (ie. it’s not
 active) in 1.2.

 Sincerely
 Meikel

 --
 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.comclojure%2bunsubscr...@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: Is there an easier way to code this? Destructuring?

2010-07-29 Thread Nikita Beloglazov
Hi, Daniel
Here's my variant
https://gist.github.com/49c6ac95b7456a150df8

Note, that in cookbook :Caffe-Moca should contain :cocoa, not :coco
And I your variant calculating drink cost works incorrectly.
(* (cost (key map-entry) (val map-entry)))
should be replaced by
(* (cost (key map-entry)) (val map-entry))

Regards,
Nikita Beloglazov

On Thu, Jul 29, 2010 at 3:02 AM, Daniel Glauser danglau...@gmail.comwrote:

 Hello folks,

 I'm working on some sample code and I have a feeling that there is an
 easier/more succinct way to code this.  Any help or RTFM with a link
 is appreciated.

 Given:

 (def cookbook {:Coffee  {:coffee 3, :sugar 1, :cream 1},
   :Decaf-Coffee{:decaf 3, :sugar 1, :cream 1},
   :Caffe-Late  {:espresso 2, :steamed-milk 1},
   :Caffe-Americano {:espresso 3},
   :Caffe-Moca  {:espresso 1, :coco 1, :steamed-milk
 1, :cream 1},
   :Cappuccino  {:espresso 2, :steamed-milk 1, :foamed-milk
 1} })

 (def cost {:coffee0.75,
   :decaf 0.75,
   :sugar 0.25,
   :cream 0.25,
   :steamed-milk  0.35,
   :foamed-milk   0.35,
   :espresso  1.00,
   :cocoa 0.90,
   :whipped-cream 1.00 })

 (def menu {:Coffee  1,
   :Decaf-Coffee2,
   :Caffe-Late  3,
   :Caffe-Americano 4,
   :Caffe-Moca  5,
   :Cappuccino  6 })

 I'm trying to write a function to print out the menu listing the cost
 of each drink.  It works (sort of) but I keep thinking there is an
 easier way.

 (defn print-menu [menu]
  (do
(println Menu:)
(doseq [[drink number] menu]
  (println (str number ,  (drink-name drink) , 
(reduce +
(map (fn [map-entry] (* (cost (key map-entry)
 (val map-
 entry (cookbook drink

 Specifically this part:
 (map (fn [map-entry] (* (cost (key map-entry) (val map-entry
 (cookbook drink))

 Is there a way I can get at the map key and value using destructuring
 without knowing what the key is ahead of time?

 Thanks,
 Daniel

 --
 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.comclojure%2bunsubscr...@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: generating a list of random numbers

2010-07-28 Thread Nikita Beloglazov
Hi, bOR_
Yes, there is easier variant:
(repeatedly 100 #(rand-int 10))

On Wed, Jul 28, 2010 at 10:24 AM, bOR_ boris.sch...@gmail.com wrote:

 Hi all,

 I have the nagging feeling that I'm missing a simple solution. Say I
 want a list of a 100 rand-int 10 numbers. Currently, I create that by
 doing (map (fn [_] (rand-int 10)) (range 100)). Is there an easier
 way?

 --
 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.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

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

Re: Clojure finally on SPOJ!

2010-07-27 Thread Nikita Beloglazov
Yes, it would be great to see example of any program, that passed all tests
on spoj written in clojure. Even if first task has got TLE...


 On Jul 25, 12:34 pm, Cachou tangtong...@gmail.com wrote:
  Even the TEST Problem will TLE!!!
 


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