Re: matching, assigning and branching in one form

2013-06-22 Thread Vincent
What about using condp?

(condp re-find msg
  #"^:(.*?)!.*PRIVMSG (.*) :(.*)" :>> #(let [[_ from to message] %] 
(logic...)))

Vincent

On Friday, 21 June 2013 17:43:50 UTC+2, Steven Arnold wrote:
>
> Hi, I am writing a simple IRC bot, pretty much just for fun, starting with 
> a simple implementation originally posted by Nurullah Akkaya on his blog. 
>  It already does what it's supposed to, which is message a fortune from 
> mod-fortune (shelling out) when someone asks it to. 
>
> However, there's a bit of code I don't like.  It looks like this: 
>
>  (cond 
>(re-find #"^:(.*?)!.*PRIVMSG (.*) :(.*)" msg) 
>  (let [[_ from to message] (re-find #"^:(.*?)!.*PRIVMSG (.*) 
> :(.*)" msg)] 
>[...logic omitted...] 
>
> What's happening is we're looking for a PRIVMSG, and if we find one, we 
> scan the message again and pull out the chunks we're interested in, and use 
> them in the "logic" part below. 
>
> The problem is I don't like maintaining two regular expressions.  I wish I 
> could use it only once, and therefore change it only once if it needs to be 
> modified.  I'd prefer to see an expression that looks like this (for 
> example): 
>
> (cond 
>  (if-matched #"^:(.*?)!.*PRIVMSG (.*) :(.*)" msg 
>[from to message] 
>(true form) 
>(optional false form))) 
>
> The if-matched acts as a let block while pulling out groups and assigning 
> to local variables at the same time.  Also, it ignores the first "match" of 
> re-find, which is the entire expression -- not generally useful to me. 
>  Maybe if-matched-groups would ignore the overall expression, and 
> if-matched would include it. 
>
> I suppose a macro might be the way to go to accomplish this, but I wonder 
> if there are any Clojure tricks that could accomplish this short of a 
> macro.  Also, do any fellow Clojurians think a macro like this is a bad 
> idea in general?  Would you suggest taking a different tack to solve this 
> problem? 
>
> Thanks in advance! 
> steven

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




Clojure 1.6 API: clojure.lang.IFn and clojure.api.API

2013-06-22 Thread Jörg Winter
So these APIs are new in 1.6-SNAPSHOT and from what I understand provide an 
integration api between Java and Clojure-Runtime (symbols and their 
invocation).
Apart from limitations which probably exist, what is the mode of execution 
for these API-calls ?

For example if a tool/IDE starts a (REPL) _process_ by calling ClojureUtils.
CLOJURE_MAIN, how am I supposed to call

API.var("clojure.core", "+");
?

How would I get the JVMs class-instance of "API" if I don't add some kind of 
inter-process communication ?

Any known projects using this new API already ?

Joerg



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




Commercial Users of Functional Programming 2013: Proposal due June 29!

2013-06-22 Thread Michael Sperber

Attached find the Call for Presentation Proposals for CUFP 2013 - do
submit a proposal, and attend one of the premier events on applied
functional programming!

More info on the event is here:

http://monkey.org/~marius/cufp.html

--
Regards,
Mike Sperber (co-chair)

Commercial Users of Functional Programming (CUFP) 2013
ICFP 2013; Boston, MA, Sep 22-24.

Proposals due June 29.

The annual CUFP workshop is a place where people can see how others
are using functional programming to solve real world problems; where
practitioners meet and collaborate; where language designers and users
can share ideas about the future of their favorite language; and where
one can learn practical techniques and approaches for putting
functional programming to work.

Giving a talk

If you have experience using functional languages in a practical
setting, we invite you to submit a proposal to give a talk at the
workshop. We are looking for both experience reports and in-depth
technical talks.

Experience reports are typically 25 minutes long (but negotiable), and
aim to inform participants about how functional programming plays out
in real-world applications, focusing especially on lessons learned and
insights gained. Experience reports don't need to be highly technical;
reflections on the commercial, management, or software engineering
aspects are, if anything, more important.

Technical talks are also 25 minutes long (also negotiable), and should
focus on teaching the audience something about a particular technique
or methodology, from the point of view of someone who has seen it play
out in practice. These talks could cover anything from techniques for
building functional concurrent applications, to managing dynamic
reconfigurations, to design recipes for using types effectively in
large-scale applications. While these talks will often be based on a
particular language, they should be accessible to a broad range of
programmers.

If you are interested in offering a talk, or nominating someone to do
so, please fill in the form at

https://www.surveymonkey.com/s/cufp

There will be a short scribes report of the presentations and
discussions but not of the details of individual talks, as the meeting
is intended to be more a discussion forum than a technical
interchange. You do not need to submit a paper, just a proposal for
your talk! Note that we will need all presenters to register for the
CUFP workshop and travel to Boston at their own expense.

Program committee

Marius Eriksen (Twitter, Inc.), co-chair
Mike Sperber (Active Group), co-chair
Mary Sheeran (Chalmers)
Andres Löh (Well-Typed)
Thomas Gazagnaire (OCamlPro)
Steve Vinoski (Basho)
Jorge Ortiz (Foursquare, Inc.)
Blake Matheny (Tumblr, Inc.)
Simon Marlow (Facebook, Inc.)

More information

For more information on CUFP, including videos of presentations from
previous years, take a look at the CUFP website at
http://cufp.org. Note that presenters, like other attendees, will need
to register for the event. Presentations will be video taped and
presenters will be expected to sign an ACM copyright release
form. Acceptance and rejection letters will be sent out by July 16th.

Please contact Marius Eriksen or Mike Sperber for questions or concerns:

marius(at)twitter(dot)com
sperber(at)deinprogramm(dot)de

Guidance on giving a great CUFP talk

Focus on the interesting bits: Think about what will distinguish your
talk, and what will engage the audience, and focus there. There are a
number of places to look for those interesting bits.
 
* Setting: FP is pretty well established in some areas, including
  formal verification, financial processing and server-side
  web-services. An unusual setting can be a source of interest. If
  you're deploying FP-based mobile UIs or building servers on oil
  rigs, then the challenges of that scenario are worth focusing
  on. Did FP help or hinder in adapting to the setting?

* Technology: The CUFP audience is hungry to learn about how FP
  techniques work in practice. What design patterns have you applied,
  and to what areas? Did you use functional reactive programming for
  user interfaces, or DSLs for playing chess, or fault-tolerant actors
  for large scale geological data processing? Teach us something about
  the techniques you used, and why we should consider using them
  ourselves.

* Getting things done: How did you deal with large software
  development in the absence of a myriad of pre-existing support that
  are often expected in larger commercial environments (IDEs, coverage
  tools, debuggers, profilers) and without larger, proven bodies of
  libraries? Did you hit any brick walls that required support from
  the community?

* Don't just be a cheerleader: It's easy to write a rah-rah talk about
  how well FP worked for you, but CUFP is more interesting when the
  talks also spend time on what doesn't work. Even when the results
  were all great, you should spend more time on the chal

multimethod noob question

2013-06-22 Thread Dennis Haupt
hi,

i was taking a look at multimethods:
(defmulti fac int)
(defmethod fac 1 [_] 1)
(defmethod fac :default [n] (*' n (fac (dec n

this works

however, this also works:

(defmulti fac print)
(defmethod fac 1 [_] 1)
(defmethod fac :default [n] (*' n (fac (dec n

what exactly is "int" or "print" doing? it doesn't seem to have an effect?

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




can't compile anything except "def"

2013-06-22 Thread Dennis Haupt
hi,

i'm trying to compiler a clojure file using intellij. the error i get is:
Clojure Compiler: java.io.IOException: The system cannot find the path
specified, compiling:(D:\cloj\MultiMethod.clj:3)

where the line number is pointing at a line that contains something that is
declared in core.clr
if i use only "def", everything works, i can compile the file

what's the problem?

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




Re: multimethod noob question

2013-06-22 Thread Chris Bilson
Dennis Haupt  writes:

> i was taking a look at multimethods:
> (defmulti fac int)
> (defmethod fac 1 [_] 1)
> (defmethod fac :default [n] (*' n (fac (dec n
>
> this works
>
> however, this also works:
>
> (defmulti fac print)
> (defmethod fac 1 [_] 1)
> (defmethod fac :default [n] (*' n (fac (dec n

This definately does not work when I try it:

 user> (defmulti fac print)
 #>
 nil
 user> (defmethod fac 1 [_] 1)
 #
 nil
 user> (fac 1)
 IllegalArgumentException No method in multimethod 'fac' for dispatch 
value: null  clojure.lang.MultiFn.getFn (MultiFn.java:160)
 1

The second arg to defmulti's job is to decide which method to call. The
print function always produces nil, so you would need a defmethod for
dispatch value nil to use print as a dispatch function:

user> (defmethod fac nil [_] 2)
#
nil
user> (fac 1)
12
nil

Notice the "12": the "1" is from print and the "2" is the value the
method produced.

Are you trying to print the dispatch values so you can see them for
tracing or something? If so, you could try something like:

user> (defn inspect [& stuff]
(println "inspect: " stuff)
(first stuff))
#>
nil
user> (inspect 1)
inspect:  (1)
1
nil
user> (defmulti fac2 inspect)
nil
nil
user> (defmethod fac2 1 [_] 1)
#
nil
user> (fac2 1)
inspect:  (1)
1
nil
user>


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




Re: can't compile anything except "def"

2013-06-22 Thread Jim - FooBar();

On 22/06/13 15:09, Dennis Haupt wrote:
where the line number is pointing at a line that contains something 
that is declared in core.clr


core.clr and intelliJ? I've never used intelliJ but I was under the 
impression it was JVM only...


are you sure you've got the right version of Clojure and properly set up 
your environment?


Jim

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

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: can't compile anything except "def"

2013-06-22 Thread Dennis Haupt
i don't know what "properly set up the environment" means exactly, but i
can run my script in the repl


2013/6/22 Jim - FooBar(); 

> On 22/06/13 15:09, Dennis Haupt wrote:
>
>> where the line number is pointing at a line that contains something that
>> is declared in core.clr
>>
>
> core.clr and intelliJ? I've never used intelliJ but I was under the
> impression it was JVM only...
>
> are you sure you've got the right version of Clojure and properly set up
> your environment?
>
> 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.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+unsubscribe@**googlegroups.com
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>

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




Re: can't compile anything except "def"

2013-06-22 Thread Jim - FooBar();

On 22/06/13 15:16, Dennis Haupt wrote:
i don't know what "properly set up the environment" means exactly, but 
i can run my script in the repl


what repl? intelliJ's repl? or a bare repl from your terminal?

do you want to use Clojure JVM or Clojure CLR?

Jim

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

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: multimethod noob question

2013-06-22 Thread Dennis Haupt
i am not trying anything, i just want to figure out what happens. this is
my output for the "print" version:
user=> (defmulti fac print)
(defmethod fac 1 [_] 1)
(defmethod fac :default [n] (*' n (fac (dec n
#'user/fac
#
#
user=> (fac 1)
10-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27-28-until
stackoverflow


2013/6/22 Chris Bilson 

> Dennis Haupt  writes:
>
> > i was taking a look at multimethods:
> > (defmulti fac int)
> > (defmethod fac 1 [_] 1)
> > (defmethod fac :default [n] (*' n (fac (dec n
> >
> > this works
> >
> > however, this also works:
> >
> > (defmulti fac print)
> > (defmethod fac 1 [_] 1)
> > (defmethod fac :default [n] (*' n (fac (dec n
>
> This definately does not work when I try it:
>
>  user> (defmulti fac print)
>  #>
>  nil
>  user> (defmethod fac 1 [_] 1)
>  #
>  nil
>  user> (fac 1)
>  IllegalArgumentException No method in multimethod 'fac' for dispatch
> value: null  clojure.lang.MultiFn.getFn (MultiFn.java:160)
>  1
>
> The second arg to defmulti's job is to decide which method to call. The
> print function always produces nil, so you would need a defmethod for
> dispatch value nil to use print as a dispatch function:
>
> user> (defmethod fac nil [_] 2)
> #
> nil
> user> (fac 1)
> 12
> nil
>
> Notice the "12": the "1" is from print and the "2" is the value the
> method produced.
>
> Are you trying to print the dispatch values so you can see them for
> tracing or something? If so, you could try something like:
>
> user> (defn inspect [& stuff]
> (println "inspect: " stuff)
> (first stuff))
> #   #>
> nil
> user> (inspect 1)
> inspect:  (1)
> 1
> nil
> user> (defmulti fac2 inspect)
> nil
> nil
> user> (defmethod fac2 1 [_] 1)
> #
> nil
> user> (fac2 1)
> inspect:  (1)
> 1
> nil
> user>
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: can't compile anything except "def"

2013-06-22 Thread Dennis Haupt
clojure jvm, intellij's repl. i'll try to run the file via commandline and
see what happens


2013/6/22 Jim - FooBar(); 

> On 22/06/13 15:16, Dennis Haupt wrote:
>
>> i don't know what "properly set up the environment" means exactly, but i
>> can run my script in the repl
>>
>
> what repl? intelliJ's repl? or a bare repl from your terminal?
>
> do you want to use Clojure JVM or Clojure CLR?
>
>
> 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.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+unsubscribe@**googlegroups.com
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>

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




Re: can't compile anything except "def"

2013-06-22 Thread Dennis Haupt
running the file works (from inside intellij), just intellijs compilation
seems to be broken i can ignore the problem for now


2013/6/22 Dennis Haupt 

> clojure jvm, intellij's repl. i'll try to run the file via commandline and
> see what happens
>
>
> 2013/6/22 Jim - FooBar(); 
>
>> On 22/06/13 15:16, Dennis Haupt wrote:
>>
>>  i don't know what "properly set up the environment" means exactly, but i
>>> can run my script in the repl
>>>
>>
>> what repl? intelliJ's repl? or a bare repl from your terminal?
>>
>> do you want to use Clojure JVM or Clojure CLR?
>>
>>
>> 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.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+unsubscribe@**googlegroups.com
>> .
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out
>> .
>>
>>
>>
>

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




Re: can't compile anything except "def"

2013-06-22 Thread Jim - FooBar();

On 22/06/13 15:21, Dennis Haupt wrote:
clojure jvm, intellij's repl. i'll try to run the file via commandline 
and see what happens


where did core.clr come from then?

can you somehow see what version of clojure your intelliJ is using? I've 
got no experience with intelliJ really...it's just that your error you 
reported earlier is very weird...


Jim

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

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: multimethod noob question

2013-06-22 Thread Chris Bilson
Dennis Haupt  writes:

> i am not trying anything, i just want to figure out what happens. this is my 
> output for the "print" version:
> user=> (defmulti fac print)
> (defmethod fac 1 [_] 1)
> (defmethod fac :default [n] (*' n (fac (dec n
> #'user/fac
> #
> #
> user=> (fac 1)
> 10-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27-28-until
> stackoverflow

Since print produces nil for a dispatch value, and nil is not 1, it
always calls your :default method.

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




Re: can't compile anything except "def"

2013-06-22 Thread Dennis Haupt
it happens with both clojure 1.5.1 and 1.4.0. when intellij tries to
compile clojure files, something strange happens. if i remove the option to
compile the files (and instead just use clojure.main and run them) there is
no problem




2013/6/22 Jim - FooBar(); 

> On 22/06/13 15:21, Dennis Haupt wrote:
>
>> clojure jvm, intellij's repl. i'll try to run the file via commandline
>> and see what happens
>>
>
> where did core.clr come from then?
>
> can you somehow see what version of clojure your intelliJ is using? I've
> got no experience with intelliJ really...it's just that your error you
> reported earlier is very weird...
>
>
> 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.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+unsubscribe@**googlegroups.com
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>

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




Re: multimethod noob question

2013-06-22 Thread Dennis Haupt
yes. all glory to the repl that makes me figure out the internals via
experiments :D
is there a way to just pass the given value along?


2013/6/22 Chris Bilson 

> Dennis Haupt  writes:
>
> > i am not trying anything, i just want to figure out what happens. this
> is my output for the "print" version:
> > user=> (defmulti fac print)
> > (defmethod fac 1 [_] 1)
> > (defmethod fac :default [n] (*' n (fac (dec n
> > #'user/fac
> > #
> > #
> > user=> (fac 1)
> >
> 10-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27-28-until
> > stackoverflow
>
> Since print produces nil for a dispatch value, and nil is not 1, it
> always calls your :default method.
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: multimethod noob question

2013-06-22 Thread Dennis Haupt
(ns experiments.MultiMethod)
(defmulti fac identity)
(defmethod fac 1 [n] (print "n:" n" <- ") 1)
(defmethod fac :default [n] (*' n (fac (dec n
(print (fac 125))

if i am getting this right, defmethod fac  [] is the
equivalent to a scala or haskell pattern match, where stuff is the "match"
and stuff2 is the complete set of original arguments?

can you provide an example where stuff2 has more information than stuff?
for fac, both are equal

thx :D


2013/6/22 Dennis Haupt 

> yes. all glory to the repl that makes me figure out the internals via
> experiments :D
> is there a way to just pass the given value along?
>
>
> 2013/6/22 Chris Bilson 
>
>> Dennis Haupt  writes:
>>
>> > i am not trying anything, i just want to figure out what happens. this
>> is my output for the "print" version:
>> > user=> (defmulti fac print)
>> > (defmethod fac 1 [_] 1)
>> > (defmethod fac :default [n] (*' n (fac (dec n
>> > #'user/fac
>> > #
>> > #
>> > user=> (fac 1)
>> >
>> 10-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27-28-until
>> > stackoverflow
>>
>> Since print produces nil for a dispatch value, and nil is not 1, it
>> always calls your :default method.
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>

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




Re: multimethod noob question

2013-06-22 Thread Chris Bilson
Dennis Haupt  writes:

> yes. all glory to the repl that makes me figure out the internals via 
> experiments :D
> is there a way to just pass the given value along?

Yes, that's what I meant by my inspect method in my original reply. It
prints the value and passes it along:

   (defn inspect [& args]
 (println "inspect:" args)
 (first args))

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




Re: multimethod noob question

2013-06-22 Thread Dennis Haupt
"identity" :)


2013/6/22 Chris Bilson 

> Dennis Haupt  writes:
>
> > yes. all glory to the repl that makes me figure out the internals via
> experiments :D
> > is there a way to just pass the given value along?
>
> Yes, that's what I meant by my inspect method in my original reply. It
> prints the value and passes it along:
>
>(defn inspect [& args]
>  (println "inspect:" args)
>  (first args))
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: try* macro to catch multiple exception classes with one body. feedback is needed.

2013-06-22 Thread Max Gonzih
I can't think about another name for my macro :). Any ideas?

Regards,
Max
On 20 Jun 2013 23:26, "Herwig Hochleitner"  wrote:

> One thing to consider: try* is a compiler builtin form. Those are
> currently not even namespaced. That might lead to confusion for readers.
>
>
> 2013/6/20 Max Gonzih 
>
>> I updated my macro to your solution, looks really simple and works like
>> before. I don't know why I overcomplicated my original solution so much :).
>>
>> Thanks again!
>>
>>
>> On Thursday, June 20, 2013 8:47:37 AM UTC+3, Meikel Brandmeyer (kotarak)
>> wrote:
>>>
>>> Hi,
>>>
>>> Am Mittwoch, 19. Juni 2013 17:00:17 UTC+2 schrieb Max Gonzih:

 Hi, I implemented small macro to catch multiple exception classes with
 one body.

 https://gist.github.com/**Gonzih/5814945

 What do you think? Are there better ways to achieve similar results?


>>> I would just extend try a simply as possible: simply add the catch-all,
>>> but keep catch and finally as is. Here my try:
>>>
>>> (defmacro try*
>>>   [& body]
>>>   (let [catch-all?   #(and (seq? %) (= (first %) 'catch-all))
>>> expand-catch (fn [[_catch-all exceptions & catch-tail]]
>>>(map #(list* 'catch % catch-tail) exceptions))
>>> transform(fn [form]
>>>(if (catch-all? form)
>>>  (expand-catch form)
>>>  [form]))]
>>> (cons `try (mapcat transform body
>>>
>>> (try*
>>>   (println :a)
>>>   (println :b)
>>>(catch-all [A B C] e (println (type e)))
>>>   (catch D _ (println "Got D!"))
>>>   (finally (println "Finally!")))
>>>
>>> expands to
>>>
>>> (try
>>>   (println :a)
>>>   (println :b)
>>>   (catch A e (println (type e)))
>>>   (catch B e (println (type e)))
>>>   (catch C e (println (type e)))
>>>   (catch D _ (println "Got D!"))
>>>   (finally (println "Finally!")))
>>>
>>> Kind regards
>>> 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.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/0Suarc57WCQ/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/groups/opt_out.
>
>
>

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




Re: Best practice for looping

2013-06-22 Thread P Martin
Ah ok - so I may be using it wrong. I am not calling the function itself - 
I was simply trying to bind local variables in a loop.

I have placed the code into gists for easier reading!

https://gist.github.com/anonymous/5841405#file-core-clj
https://gist.github.com/anonymous/5841420#file-vec-clj

Is there another way to mimic procedural type looping?

On Saturday, June 22, 2013 2:39:01 AM UTC-4, Cedric Greevey wrote:
>
> An algorithm like that generating StackOverflowErrors suggests it's 
> recursing deeply, which suggests you're not using recur *enough*. If the 
> function calls itself, try to see if you can get that call into tail 
> position and change it to "recur".
>
>
> On Fri, Jun 21, 2013 at 4:06 PM, P Martin 
> > wrote:
>
>> Hi,
>>
>> I am new to clojure and I am trying to reimplement some optimization code 
>> that uses gradient descent. I have attached the source to this post. My 
>> experience with gradient descent is in Matlab, which is procedural.
>>  
>> When I run my function gradient-descent I supply step sizes and error 
>> values of 0.01, it runs correctly and gives me good results. However, if I 
>> decrease the error value below 0.001 it produces a stack overflow error. I 
>> get the same error if my step value goes down to 0.001.
>>
>> Is my looping mechanism correct and I am just having numerical 
>> limitations? Am I abusing loop/recur? Any suggestions/critiques would be 
>> great!
>>
>> Thanks,
>> Patrick
>>
>> -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

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




Re: Best practice for looping

2013-06-22 Thread Gary Trakhman
Do you have the stack trace? It's not simple to run the code, but I made a
github project so we can look at it easier.
https://github.com/gtrak/grad-descent-test

When I run (gradient-descent example-grad [0 1] 0.001 0.001)

Here's the actual problem:
grad-descent.core> (pst *e)
StackOverflowError
clojure.lang.LazySeq.seq (LazySeq.java:60)
clojure.lang.RT.seq (RT.java:484)
clojure.core/seq (core.clj:133)
clojure.core/map/fn--4211 (core.clj:2490)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:60)
clojure.lang.RT.seq (RT.java:484)
clojure.core/seq (core.clj:133)
clojure.core/map/fn--4211 (core.clj:2490)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:60)
clojure.lang.RT.seq (RT.java:484)

The actual problem is in the vec functions, switching them to mapv fixes it.

grad-descent.core> (gradient-descent example-grad [0 1] 0.001 0.001)
[0.0 0.018256499170212572]



On Sat, Jun 22, 2013 at 12:12 PM, P Martin  wrote:

> Ah ok - so I may be using it wrong. I am not calling the function itself -
> I was simply trying to bind local variables in a loop.
>
> I have placed the code into gists for easier reading!
>
> https://gist.github.com/anonymous/5841405#file-core-clj
> https://gist.github.com/anonymous/5841420#file-vec-clj
>
> Is there another way to mimic procedural type looping?
>
> On Saturday, June 22, 2013 2:39:01 AM UTC-4, Cedric Greevey wrote:
>
>> An algorithm like that generating StackOverflowErrors suggests it's
>> recursing deeply, which suggests you're not using recur *enough*. If the
>> function calls itself, try to see if you can get that call into tail
>> position and change it to "recur".
>>
>>
>> On Fri, Jun 21, 2013 at 4:06 PM, P Martin  wrote:
>>
>>> Hi,
>>>
>>> I am new to clojure and I am trying to reimplement some optimization
>>> code that uses gradient descent. I have attached the source to this post.
>>> My experience with gradient descent is in Matlab, which is procedural.
>>>
>>> When I run my function gradient-descent I supply step sizes and error
>>> values of 0.01, it runs correctly and gives me good results. However, if I
>>> decrease the error value below 0.001 it produces a stack overflow error. I
>>> get the same error if my step value goes down to 0.001.
>>>
>>> Is my looping mechanism correct and I am just having numerical
>>> limitations? Am I abusing loop/recur? Any suggestions/critiques would be
>>> great!
>>>
>>> Thanks,
>>> Patrick
>>>
>>> --
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>>
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@**googlegroups.com
>>>
>>> For more options, visit this group at
>>> http://groups.google.com/**group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@**googlegroups.com.
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Best practice for looping

2013-06-22 Thread Gary Trakhman
I think the way to understand what's going on is to realize that laziness
(coming from map) creates extra thunks, for each iteration, you're creating
an extra stack frame to dereference the elements of the lazy seq.

(defmacro lazy-seq
  "Takes a body of expressions that returns an ISeq or nil, and yields
  a Seqable object that will invoke the body only the first time seq
  is called, and will cache the result and return it on all subsequent
  seq calls. See also - realized?"
  {:added "1.0"}
  [& body]
  (list 'new 'clojure.lang.LazySeq (list* '^{:once true} fn* [] body)))

So, if your maps get numerous and layered enough, it's no longer possible
to deref values from them.

I've created a simple example that demonstrates this.
user> (defn my-map
  [n]
  (first (loop [out [1] counter n]
   (if (<= counter 0)
 out
 (recur (map identity out) (dec counter))
#'user/my-map
user>  (my-map 1)
1
user>  (my-map 10)
1
user>  (my-map 100)
1
user>  (my-map 1000)
1
user>  (my-map 1)
StackOverflowError   clojure.core/seq (core.clj:133)
user> (pst *e)
StackOverflowError
clojure.core/seq (core.clj:133)
clojure.core/map/fn--4087 (core.clj:2426)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:60)
clojure.lang.RT.seq (RT.java:473)
clojure.core/seq (core.clj:133)
clojure.core/map/fn--4087 (core.clj:2426)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:60)
clojure.lang.RT.seq (RT.java:473)
clojure.core/seq (core.clj:133)
clojure.core/map/fn--4087 (core.clj:2426)
nil
user>




On Sat, Jun 22, 2013 at 1:10 PM, Gary Trakhman wrote:

> Do you have the stack trace? It's not simple to run the code, but I made a
> github project so we can look at it easier.
> https://github.com/gtrak/grad-descent-test
>
> When I run (gradient-descent example-grad [0 1] 0.001 0.001)
>
> Here's the actual problem:
> grad-descent.core> (pst *e)
> StackOverflowError
>  clojure.lang.LazySeq.seq (LazySeq.java:60)
> clojure.lang.RT.seq (RT.java:484)
> clojure.core/seq (core.clj:133)
>  clojure.core/map/fn--4211 (core.clj:2490)
> clojure.lang.LazySeq.sval (LazySeq.java:42)
> clojure.lang.LazySeq.seq (LazySeq.java:60)
>  clojure.lang.RT.seq (RT.java:484)
> clojure.core/seq (core.clj:133)
> clojure.core/map/fn--4211 (core.clj:2490)
>  clojure.lang.LazySeq.sval (LazySeq.java:42)
> clojure.lang.LazySeq.seq (LazySeq.java:60)
> clojure.lang.RT.seq (RT.java:484)
>
> The actual problem is in the vec functions, switching them to mapv fixes
> it.
>
> grad-descent.core> (gradient-descent example-grad [0 1] 0.001 0.001)
> [0.0 0.018256499170212572]
>
>
>
> On Sat, Jun 22, 2013 at 12:12 PM, P Martin wrote:
>
>> Ah ok - so I may be using it wrong. I am not calling the function itself
>> - I was simply trying to bind local variables in a loop.
>>
>> I have placed the code into gists for easier reading!
>>
>> https://gist.github.com/anonymous/5841405#file-core-clj
>> https://gist.github.com/anonymous/5841420#file-vec-clj
>>
>> Is there another way to mimic procedural type looping?
>>
>> On Saturday, June 22, 2013 2:39:01 AM UTC-4, Cedric Greevey wrote:
>>
>>> An algorithm like that generating StackOverflowErrors suggests it's
>>> recursing deeply, which suggests you're not using recur *enough*. If the
>>> function calls itself, try to see if you can get that call into tail
>>> position and change it to "recur".
>>>
>>>
>>> On Fri, Jun 21, 2013 at 4:06 PM, P Martin  wrote:
>>>
 Hi,

 I am new to clojure and I am trying to reimplement some optimization
 code that uses gradient descent. I have attached the source to this post.
 My experience with gradient descent is in Matlab, which is procedural.

 When I run my function gradient-descent I supply step sizes and error
 values of 0.01, it runs correctly and gives me good results. However, if I
 decrease the error value below 0.001 it produces a stack overflow error. I
 get the same error if my step value goes down to 0.001.

 Is my looping mechanism correct and I am just having numerical
 limitations? Am I abusing loop/recur? Any suggestions/critiques would be
 great!

 Thanks,
 Patrick

 --
 --
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com

 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@**googlegroups.com

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+u...@**googlegroups.com.

 For more

Packaging data_readers.clj with a Clojar

2013-06-22 Thread Joel Holdbrooks
Tagged literals are really neat. The other day I discovered what seems to 
be a fairly good use case for them (see discussion 
here). 
At the time I wasn't sure if data_readers.clj could be packaged with a 
Clojar but it appears it can. 

While part of me finds this attractive, I wonder, is this a good idea?

-- 
-- 
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: vectorz-clj 0.10.0

2013-06-22 Thread Mike Anderson
Pleased to announce the latest 0.10.0 release of vectorz-clj, a 
matrix/vector maths library for Clojure

vectorz-clj is designed so that you don't have to compromise: offering both 
high performance (about as fast as you can get on the JVM) and an idiomatic 
high-level Clojure API.

New and notable changes:
- Faster implementations for many standard mathematical functions - sqrt, 
abs, exp, log, sin etc.
- Significant performance enhancements for N-dimensional arrays where N>2
- Improved interop with regular Clojure data structures (conversions 
to/from Clojure persistent vectors)
- Specialised implementations for common functions, e.g. add-product
- Integration of core.matrix.stats for statistical functions on vectors and 
matrices (mean, variance etc.)
- Updates to latest versions of major dependencies (core.matrix 0.8.0, 
vectorz 0.15.0)

vectorz-clj is an implementation of core.matrix, and supports all features 
of the current core.matrix API. This is a big advantage: if you use  the 
core.matrix API and decide to switch to a different implementation at a 
later date (e.g. to take advantage of optimised native libraries) then most 
of your code won't need to change.

Essential links:
Clojars: https://clojars.org/net.mikera/vectorz-clj
GitHub: https://github.com/mikera/vectorz-clj

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




Re: can't compile anything except "def"

2013-06-22 Thread Colin Fleming
Which version of the IntelliJ plugin are you using? You can see this by
opening the settings, selecting plugins then selecting the La Clojure
plugin. In recent versions the compiler has changed and I've had occasional
problems with it.


On 23 June 2013 02:29, Dennis Haupt  wrote:

> it happens with both clojure 1.5.1 and 1.4.0. when intellij tries to
> compile clojure files, something strange happens. if i remove the option to
> compile the files (and instead just use clojure.main and run them) there is
> no problem
>
>
>
>
> 2013/6/22 Jim - FooBar(); 
>
>> On 22/06/13 15:21, Dennis Haupt wrote:
>>
>>  clojure jvm, intellij's repl. i'll try to run the file via commandline
>>> and see what happens
>>>
>>
>> where did core.clr come from then?
>>
>> can you somehow see what version of clojure your intelliJ is using? I've
>> got no experience with intelliJ really...it's just that your error you
>> reported earlier is very weird...
>>
>>
>> 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.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+unsubscribe@**googlegroups.com
>> .
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out
>> .
>>
>>
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




what execurtes what in clojure

2013-06-22 Thread jayvandal
in a project file the
:main my-website.server)
Is this like a go to statement or a do like statement

it seems that the leiningen  has default to the welcome clj file.If it 
doesn't find the welcome file what does leiningen do?

In the my-website.server clj file , the main function ends with a 
:ns 'my-website])))
what does this statement do??
 
 thanks jvandal 

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




Re: what execurtes what in clojure

2013-06-22 Thread Gary Trakhman
Check out
https://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj#L404

and https://github.com/clojure/clojure/blob/master/src/jvm/clojure/main.java


On Sat, Jun 22, 2013 at 7:20 PM, jayvandal  wrote:

> in a project file the
> :main my-website.server)
> Is this like a go to statement or a do like statement
>
> it seems that the leiningen  has default to the welcome clj file.If it
> doesn't find the welcome file what does leiningen do?
>
> In the my-website.server clj file , the main function ends with a
> :ns 'my-website])))
> what does this statement do??
>
>  thanks jvandal
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Packaging data_readers.clj with a Clojar

2013-06-22 Thread Gary Trakhman
I don't think there's a way to make aliases for reader literals, which you
would want in order to avoid breaking this rule:
"Reader tags without namespace qualifiers are reserved for Clojure."
from http://clojure.org/reader#The Reader--Tagged Literals

But I haven't tried it myself, is that the case?

Seems like you could possibly bind *data-readers* for only the duration of
the evaluation of that code, that might be a dirty workaround.  You could
put those templates in special files that are read this way.


On Sat, Jun 22, 2013 at 2:14 PM, Joel Holdbrooks wrote:

> Tagged literals are really neat. The other day I discovered what seems to
> be a fairly good use case for them (see discussion 
> here).
> At the time I wasn't sure if data_readers.clj could be packaged with a
> Clojar but it appears it can.
>
> While part of me finds this attractive, I wonder, is this a good idea?
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Cambridge (UK) Clojure user group

2013-06-22 Thread Ray Miller
The Cambridge (UK) Clojure group used to meet monthly, but has recently 
lost momentum. I'm trying to turn that around and get us back on track with 
a regular monthly meet-up. If you are in the Cambridge area and might be 
interested in attending these meet-ups, please take a few minutes to 
complete our short survey: .

Ray.

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




Re: representing clojure source code as data?

2013-06-22 Thread kovas boguta
On Fri, Jun 21, 2013 at 6:08 PM, Brandon Bloom wrote:

> You've outlined 2 out of the 3 interesting (to me) shapes: 1) raw data
> structures and 2) datoms. I think that the 3rd interesting one is a
> map/vector tree, like the CLJS analyzer output.
>

By "raw data structures", you mean the concrete implementing classes, a la
clojure.lang.PersistentVector?

What I had in mind was more like #3, a map/vector tree, but you're right
theres an extra interesting shape there.

Here's a minimal design for what I'm talking about:


"(quote 1)" ->
{:head :list :body [quote 1]}

" '1 " ->
{:head :quote :body [1]}

#{1 2 3} ->
{:head :set :body [1 2 3]}

All syntax is turned into first class representations. Reader macros and
datastructure literals are indexed by special keywords; primitives stand
for themselves without extra wrapping.

The original structure of the source is preserved 100%. You would then have
an EDN-to-in-memory-raw-datastructures reader to read from this into live
running code.

(this is basically the EDN-ified form of Mathematica expressions, and its
particularly well suited to symbolic manipulation and pattern matching)

One can then go from this, in a series of passes, into an AST (this is the
"convert to normal form and add semantics" step) and then into compiled
code. And have a chance at mapping exceptions back to the original source,
and do analysis between the source, the AST, and the error.


The two languages to describe are EDN and Clojure. You can further break
> Clojure down by host platform, and even potentially further (for example:
> pre and post macro expansion variants of the language).
>

I think I understand what you mean, though lemme try to rephrase it:

Clojure code is EDN data + a set of non-EDN constructs; doing with with
100% EDN is the problem I'm trying to solve.

When attempting to output EDN data, a different but related set of non-EDN
constructs messes things up.

I definitely agree that's also a problem, TLs are one case and definitely
agree with the direction there, though what about the other cases? Random
java objects and whatnot.

Those should be output in an EDN way, though its unclear what they would
mean when read. Would there be any attempt to convey their contents or
characteristics?

Issues around this are a big headscratcher for Session, so I'd be happy
with some standard solution here.


> As for the Code variant, the tools.analyzer library and CLJS compilers
> have an internal AST representation that should eventually be standardized.
> The important thing there for me is that we differentiate fundamental
> properties of AST nodes and synthesized/derived attributes that are
> attached to each node.
>

The datomic representation is particularly interesting for this.

Every program that computes from the source code can just add its results
as new attributes. This includes both the traditional compiler passes, as
well as additional testing & analysis, or even the results of running the
code.

So there is a single source of truth about the source code and its
consequences, and different layers have access to the big picture.

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