StackOverflow TV Opportunity to Promote Clojure

2014-09-03 Thread A. Webb
StackOverflow just announced an experimental project to produce videos in its New York City office. This could be a great opportunity to polish up one of your presentations and promote Clojure to a wide audience. No speaker fees, but reasonable travel costs covered. Post: http://meta.stackoverf

Re: Best way to create a namespace at runtime from a web app

2014-04-24 Thread A. Webb
Have you tried the aptly named create-ns ? -- 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

Re: regex

2014-04-18 Thread A. Webb
On Friday, April 18, 2014 8:28:03 AM UTC-5, Thumbnail wrote: > > > I had a couple of insights. First, to allow the dfa to be generated >> programmatically, I changed it from a map to a vector. This means >> that the next state can just be an integer. Second, I decided that >> the terminal s

Re: The Cons in iterate's return value

2014-04-17 Thread A. Webb
On Wednesday, April 16, 2014 10:35:14 PM UTC-5, Mars0i wrote: > > > But then should realized? be able to deal with a Cons containing a LazySeq? > > (Is this an issue worthy of JIRA? I've never submitted there, and am not > sure I know enough to do so. Willing to try to figure it out.) > No, re

Re: Questions regarding Map vs Record and usage

2014-04-09 Thread A. Webb
You can refer-in the first (factory function) to another namespace; for the second you'd have to import the class. I prefer the first. The third is special syntax for the reader. As to the last question, I don't know, but it allows you to define your own. For example, (defrecord Book [tit

Re: Name for this pattern: side-effect from swap!

2014-04-08 Thread A. Webb
See https://groups.google.com/d/topic/clojure/2dHvX7bf7nA/discussion, http://stackoverflow.com/a/22409846/1756702, where the old and new state of an atom is returned using the lower-level compare-and-set! operation. On Tuesday, April 8, 2014 10:41:50 AM UTC-5, John Hume wrote: > > I sometimes fi

Re: Lazy sequence - how they work internally

2014-04-08 Thread A. Webb
On Tuesday, April 8, 2014 7:57:10 AM UTC-5, sorin cristea wrote: > > > What exactly you mean by '*The point was you aren't using lazy-seq as > intended here since you are always creating a singleton sequence*' ? In > my sum function...I intend to compute sum of elements of a collection. > L

Re: Lazy sequence - how they work internally

2014-04-07 Thread A. Webb
The point was you aren't using lazy-seq as intended here since you are always creating a singleton sequence. What's going on behind the scenes here is in effect just trampolining thunks. (defn thunked-sum [sum coll] (if-let [[x & more] (seq coll)] (fn [] (thunked-sum (+ sum x) more))

Re: How do I detect the end of a file without catching an exception?

2014-04-07 Thread A. Webb
On Monday, April 7, 2014 1:14:40 PM UTC-5, guns wrote: > > On Mon 7 Apr 2014 at 11:07:37AM -0700, Simon Brooke wrote: > > OK, the second question I've sort of answered for myself, by riffing on > the > > source of line-seq: > > > > (defn expr-seq > > "Returns forms from src (assumed to b

Re: Fn as value matcher in core.match

2014-04-07 Thread A. Webb
It is always matching the first clause because it is getting translated into a `let` binding. In match, the left-hand side `get` is just a symbol, not the `var` it resolves to, so might as well be `(let [fun assoc] (match fun foo "foo!"))` where `foo` will just be bound to `assoc`. Match does n

Re: remove first?

2014-04-02 Thread A. Webb
On Wednesday, April 2, 2014 3:39:47 PM UTC-5, Christopher Howard wrote: > > On Wed, 2 Apr 2014 14:07:47 -0600 > Timothy Baldridge > wrote: > > > I don't know of anything built-in, but this should do the trick: > > > > (defn remove-first [f [head & tail]] > > (if (f head) > > tail >

Re: Basic string modification question

2014-04-02 Thread A. Webb
Using subs (no need for join) is the way I would go, just define (defn replace-at [s n c] (str (subs s 0 n) c (subs s (inc n (replace-at "hello" 1 "a") ;=> "hallo" and carry on. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To po

Re: REPL: viewing data structures containing infinite lists

2014-04-01 Thread A. Webb
On Tuesday, April 1, 2014 11:00:37 AM UTC-5, Andreas Liljeqvist wrote: > > Is there any good reason for not providing a default value for > *print-length*? > I think that if you *really* want to print a list containing 100K items, > you would have to set *print-length*. > > Basically it seems l

Re: Strange behaviour for proxy when two abstract classes are passed in

2014-04-01 Thread A. Webb
On Monday, March 31, 2014 4:34:17 PM UTC-5, zcaudate wrote: > > I know this is a silly example but I am curious to know what is happening > with the proxy method. > > I have set up two calls to proxy: > > 1. > (def cp > (proxy [java.util.AbstractMap clojure.asm.ClassVisitor] [])) > > 2. >

Re: Function from a symbolic expression

2014-03-31 Thread A. Webb
On Monday, March 31, 2014 12:13:25 PM UTC-5, Jony Hudson wrote: > > > (defmacro functionalise > [ex var] > (let [arg (gensym) > body (postwalk-replace {var arg} ex)] > `(fn [~arg] ~body))) > > This works as written, it is just that macros do not evaluate their arguments, so you d