Re: Pattern of Succinctness

2012-08-13 Thread dmirylenka
Should be (filter (comp not nil?) coll)

On Sunday, August 12, 2012 9:44:11 PM UTC+2, Pierre-Henry Perret wrote:
>
> I prefer  (filter (partial not nil?) coll)  as a HOF
>
> Le dimanche 12 août 2012 20:46:59 UTC+2, rmarianski a écrit :
>>
>> On Sun, Aug 12, 2012 at 11:22:55AM -0700, Takahiro Hozumi wrote: 
>> > > (filter (partial not nil?) coll) 
>> > You mean (filter (comp not nil?) coll). 
>> > I'm not sure which is more readable, but thanks for Meikel and Alex, I 
>> now 
>> > prefer (remove nil? coll). 
>>
>> remove is better in this case, but for posterity (comp not nil?) can be 
>> spelled as (complement nil?) 
>>
>> Robert 
>>
>

-- 
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: Pattern of Succinctness

2012-08-13 Thread dmirylenka
Using threading operators + anonymous functions sometimes yields more 
succinct code than using HOF,
especially because 'partial' and 'comp' are such long names:

(comp count (partial filter nil?) (partial map foo))

#(->> %  (map foo)  (filter nil?) count)

On Sunday, August 12, 2012 7:35:16 PM UTC+2, Takahiro Hozumi wrote:
>
> Hi,
> I would like to know common technics that make code succinct.
>
> For example:
> (or (:b {:a 1}) 0)
> (:b {:a 1} 0)
>
> (if-not x 1 2)
> (if x 2 1)
>
> (filter #(not (nil? %)) coll)
> (filter identity coll) ;; nearly equal
>
> Please let me know any tips you found.
>
> Cheers,
> Takahiro.
>

-- 
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
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  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-tasks.
>> I use quil for 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

Fitting data to distributions with Incanter

2012-08-13 Thread myriam abramson
Sorry, for posting here. I am not sure if the Incanter mailing list is
active nowadays and I need an answer to this question soon.
Is there an easy way to fit data to distributions with Incanter similar to
fitdistr in R?
TIA

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

Pattern/quote equivalent for CLJS?

2012-08-13 Thread Shantanu Kumar
Hi,

I am looking for an equivalent of java.util.regex.Pattern/quote[1] for
CLJS. Can anybody suggest a solution? (Maybe using Google Closure?) I
found something relevant on StackOverflow[2] that I might try to
proceed with, but thought to ask the community first.

[1] 
http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#quote(java.lang.String)
[2] 
http://stackoverflow.com/questions/3614440/replicate-the-functionality-of-javas-pattern-quote-in-a-javascript-regexp

Shantanu

-- 
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 dmirylenka
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(); 
> 
> > wrote:
>
>> 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...@**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

Fixing a broken Java library

2012-08-13 Thread martin_clausen
I am using the otherwise nice java-libpst 
(http://code.google.com/p/java-libpst/) library to extract data from .pst 
files produced by Outlook for further processing in Clojure.

Unfortunately the method 
(http://code.google.com/p/java-libpst/source/browse/trunk/com/pff/PSTMessage.java#860)
 
that reads which categories a mail is "tagged" with, is broken. So my first 
thought is of course to fix this using Clojure, but this has turned out to 
be harder said than done. I have looked into proxy, which turned out to be 
a dead end (if I am not mistaken), as the objects representing a mail 
message must be produced using a static factory method.

Any hints on how to implement the broken method 
(http://code.google.com/p/java-libpst/source/browse/trunk/com/pff/PSTMessage.java#860)
 
greatly appreciated. Please note that the Clojure function  replacing the 
broken method must be able to access several protected fields within the 
Java class.

-- 
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 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(); wrote:
>>
>>> 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=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

clojure.logic project.clj file

2012-08-13 Thread Brent Millare
I think the :source-path line in project.clj should be :source-paths 
["src/main/clojure"]. Is :source-path still looked up in leiningen2?

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

currying and partial evaluation

2012-08-13 Thread Michael Jaaka
nice, thanks a lot

-- 
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: Fixing a broken Java library

2012-08-13 Thread Jonathan Fischer Friberg
gen-class supports both static methods and protected vars.

http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/gen-class

(see :exposes in the second for protected access).

Jonathan

On Mon, Aug 13, 2012 at 8:53 PM, martin_clausen wrote:

> I am using the otherwise nice java-libpst (
> http://code.google.com/p/java-libpst/) library to extract data from .pst
> files produced by Outlook for further processing in Clojure.
>
> Unfortunately the method (
> http://code.google.com/p/java-libpst/source/browse/trunk/com/pff/PSTMessage.java#860)
> that reads which categories a mail is "tagged" with, is broken. So my first
> thought is of course to fix this using Clojure, but this has turned out to
> be harder said than done. I have looked into proxy, which turned out to be
> a dead end (if I am not mistaken), as the objects representing a mail
> message must be produced using a static factory method.
>
> Any hints on how to implement the broken method (
> http://code.google.com/p/java-libpst/source/browse/trunk/com/pff/PSTMessage.java#860)
> greatly appreciated. Please note that the Clojure function  replacing the
> broken method must be able to access several protected fields within the
> Java class.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Re: clojure.logic project.clj file

2012-08-13 Thread David Nolen
On Mon, Aug 13, 2012 at 4:38 PM, Brent Millare  wrote:
> I think the :source-path line in project.clj should be :source-paths
> ["src/main/clojure"]. Is :source-path still looked up in leiningen2?

Is there something specific you are trying to do?

David

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


needs a reader syntax for floats

2012-08-13 Thread Matthew Kennedy
While doing image processing in Clojure recently it occured to me that it 
would be handy to have a specifier suffix for distinguishing between 
doubles and floats as libraries in this domain often use single precision 
floats instead of double precision (or mixtures of both). 

My code frequently contains things like 

[(float 0.12) (float 0.33) (float 0.56)]. 

e.g. image convolution kernels etc. I'd much rather it look like this:

[0.12f 0.33f 0.56f]

As far as I can tell there's no way to do this with user code. I think it 
would have to be done within the Clojure runtime by adjusting 
ListReader.java to change the floating point reader regex and switching on 
an suffix character.

The current behavior is:

  123.32M -> BigDecimal
  123.32 -> double

I propose:

  123.32M -> BigDecimal
  123.32 -> double
  123.32f -> float
  123.32d -> double

I already have a prototype which implements the literal syntax above. Is 
this worthwhile pushing this feature for inclusion in Clojure itself? What 
kind of issues might I be overlooking? About all I can think of is the 
printer needs to print the "d" or "f" when *print-readably* is non-nil.

Matt

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