Cameron Pulsford wrote:
> Is there a way to do this? Besides cleaning up function signatures is
> this a premature optimization to begin with?
>
> (declare *macros*)
>
> (defn macro-expand [tokens]
> (map #(get *macros* % %) tokens))
>
> (defn compile-op [op]
> (macro-expand op))
>
> (defn ass
On Aug 9, 7:54 pm, CuppoJava wrote:
> Hello everyone,
> Just for educational purposes, I'm writing a simple lisp compiler and
> am stuck on a small problem.
>
> I'm trying to write a function called (compile-function), which will
> take a function as input and compile it.
>
> If that function ca
On May 31, 10:35 am, alux wrote:
> [ ] A special form is what can be implemented by a macro.
That depends. My understanding is that a special form is something
that is "fundamental" to the language, that the evaluator handles as a
special case. That is, they need to be implemented in the compil
On May 30, 12:32 am, Daniel Borchmann
wrote:
> The same happens if i goes up to 100, 1000, ... Is this a bug or is
> this a fundamental misconception of mine?
You're using them wrong. Transients are not imperative data
structures. You need to capture the return value of assoc! and use
that as
On May 18, 2:23 am, Base wrote:
> (defn lazy-date-seq [d1 d2]
> (let [start (-> d1
> (.dayOfMonth)
> (.withMinimumValue))]
> (lazy-seq
> (cons start
> (if (joda/before? start d2)
> (lazy-date-seq (.plusMonths start 1) d2))
>
On May 11, 11:18 am, Donell Jones
wrote:
> Hi Team,
> I am really interested in functional programming. But I am asking
> myself, what if the project get bigger, like the software Runa realise
> with Clojure. In OOP we got diagrams like UML to visualise this. But
> what can we do in FP ? Are there
On May 4, 10:40 pm, Bryce wrote:
> I have a macro, deriv, that produces an expression, and I'd like to
> create another macro that turns this into a function. So far I have
>
> (defmacro deriv-fn [fn-args exp v degree]
> `(fn ~fn-args (deriv ~exp ~v ~degree)))
>
> Which of course doesn't work
On May 2, 11:14 pm, Mike Meyer wrote:
> On Sun, 02 May 2010 13:06:56 +1000
> To get behavior similar to the vector constructs, you want to use
> list, which works like vector, except returning a list instead of a
> vector: (list 1 2 3 (print :hello)). It seems that what's missing here
> is a sy
On Apr 30, 9:46 pm, russellc wrote:
> Should this compile?
>
> (defprotocol P (p [this]))
> (defrecord R [k] P (p [{:keys [k]}] k))
>
> java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot
> be cast to clojure.lang.Symbol
defrecord doesn't yet support destructuring as far as I k
On Apr 28, 5:00 am, Richard Newman wrote:
> Opinions, thoughts, critiques, "you're insane"s, etc. welcome.
The patches look fine to me and the change is well justified since you
have a real use case. I don't think restricting deftype to final
classes would serve any real purpose. I'd just go a
> *clojure-version*
> {:interim true, :major 1, :minor 1, :incremental 0, :qualifier
> "alpha"}
>
Looks like you have some old version of 1.1 prior to release. The
release version of 1.1 shouldn't have the alpha qualifier.
Try upgrading.
--
You received this message because you are subscribe
On Apr 19, 1:17 pm, Joel Gluth wrote:
> (def floatarray (make-array Float/TYPE 2))
> (for [i (range (alength floatarray))] (aset floatarray i (float ([1 2]
> i
You can just do (into-array Float/TYPE [1.0 2.0])
There is no need to explicitly cast the vector items as they would be
boxed anyway
On Apr 16, 5:25 pm, Asim Jalis wrote:
> > It does conform to the pattern that the bound variable precedes the
> > value to bind in forms like let. A benefit of this ordering is that
> > destructuring patterns like {:keys [a b c]} are unambiguous.
>
> Hi Per,
>
> Could you explain the rationale f
On Apr 16, 11:59 am, Bytesource wrote:
> Hi,
>
> I am currently reading "Programming Clojure" but got stuck at the
> destructuring done in the "head-overlaps-body?" function call that is
> part of the "snake" game:
>
> (defn head-overlaps-body? [{[head & body] :body}]
> (includes? body head))
> Hopefully you can see that this syntax falls out of the direct construction
> of maven Model object, unmediated by intermediate syntax or data structuring.
> So there's a good reason for the way it looks.
>
Right. Thanks for the thorough explanation. It's not so bad if you
quote the vectors i
Looks cool. This should help the XML-allergic :)
Though, is there a reason why all symbol arguments to defmodel have to
be quoted? It looks rather unpleasant. Seems like you should be able
to fix that by changing the body of defmaven to
`(reset! *MODEL* (Model ~@(for [a args] `(quote ~a
Ano
On Apr 7, 12:25 am, Sophie wrote:
> Just curious
> - what folks think of fixed-positional-keyword params
> - whether it was considered for Clojure
I don't know for certain whether Rich ever considered smalltalk-style
parameters, but I doubt it.
I do like them, though; in Objective-C and Sma
On Apr 6, 8:16 am, Zach Tellman wrote:
> Possibly this fall out from the latest commit requiring an explicit
> 'this' reference (ba6cc3b), I haven't checked any versions but the
> most recent.
>
> user> (defprotocol Protocol (f [a b & c]))
> Protocol
> user> (def p (reify Protocol (f [a b & c] [a
> The def was for legibility (or I was going for legibility). Speaking
> of redefing, is there a way to block a redef so I or someone else
> doesn't monkey-patch a function?
You can set a validator on the Var to prevent accidents. However,
someone who really wants to redefine a function can just
On Mar 29, 1:26 am, strattonbrazil wrote:
> Is this the common way to do it?
>
> (def sister (assoc brother :name "Cindy"))
>
Please note that actually def'ing each value is not what you're
supposed to do :) def is reserved for global constants and dynamically
rebindable variables, and redefing
> Specifically, I prefer to define the important components of my
> software as Java interfaces. Partly to see myself think, partly
> because it just makes more sense to me. I then want to implement these
> interfaces using gen-class and clojure functions and pass resulting
> objects as function ar
This looks neat. I probably won't find much use for it though, as my
input method already has this functionality, and even that doesn't get
much use due to the fact that I am horrible at writing kanji with the
mouse (I'm left-handed, but my mouse-hand is right.)
If you have no plans to try to make
On Mar 26, 8:53 am, Per Vognsen wrote:
> It's not semantic nitpicking. There's a clear-cut difference a piece
> of reusable code with a function that can be called to generate a
> bundled Windows installer based on a set of arguments versus something
> that only works as part of a build system
jfr wrote:
> Hello,
>
> I've just started to play a little bit with clojure to get a feel for
> the language. It seems to be quite interesting (and it's a relief to
> leave my clumsy IDE behind and use Emacs). Concerning immutable data:
> Is the following code ok or should (must) I use transients
On Mar 19, 6:53 pm, Andrzej wrote:
> I've been toying with various implementations of reduce-like
> functions, trying to do something "smarter" than a simple iteration
> over a collection of data. This hasn't worked out very well, my
> implementation is a lot (~50x) slower than a simple loop. Co
On Mar 20, 1:52 pm, Glen Rubin wrote:
> Hey all,
>
> I am working through the problems on project euler. On question
> number 11 (http://projecteuler.net/index.php?section=problems&id=11),
> I was unable to come up with a solution, so I cheated and looked at
> some other people's answer's here:
On Mar 17, 1:17 am, "Steven E. Harris" wrote:
> Michał Marczyk writes:
> > a State-using programme builds up a stateful computation first, then
> > uses runState (or perhaps execState / evalState) to run it as a whole;
> > only at this final step does the initial state actually get poured
> > i
> Is there more to it than, "Monadic functions must return monadic
> values"?
>
> Any clarifying advice would be welcome.
>
Gah, I already wrote a reply, but looks like I lost it somehow. To
summarise:
I think one of the main benefits of the monad abstraction is the
uniformity of all monads. ie.
*facepalm* I should've known GG was just hiding the post from me.
--
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 you
> What would be lost by defining Clojure bind operator like this:
>
> (fn m-bind-state [mv f]
> (fn [s]
> (let [[v ss] (mv s)]
> (f v ss
>
> Is there more to it than, "Monadic functions must return monadic
> values.
My first thought was that it would be problematic for the
On Mar 3, 7:47 pm, cageface wrote:
> I've been reading through the examples of "OO" in clojure using multi-
> methods and they certainly seem very flexible and powerful. I'm
> wondering, however, how people handle interface & library design. If
> people can implement "objects" as maps, structs, or
On Mar 1, 9:55 am, Richard Newman wrote:
> (defn house-sale-profit
> [house-sales-price house-sale-expenses]
> (- house-sales-price house-sale-expenses))
I'd like to note that if you do this, you might just as well use the -
function directly. It's not as flexible if the profit ca
On Feb 28, 7:36 pm, reynard wrote:
> Perhaps my choice of function names (abstract and concrete) for my
> original post is not very appropriate. I did not mean to apply the OO
> concept of abstract class, abstract methods, etc. Since it seems that
> my original post did not convey my query cle
On Feb 28, 4:03 pm, "Heinz N. Gies" wrote:
> How about reducing it?
>
> Something along the limes of: (not tested)
>
> (reduce (fn [lists number]
> (update-in lists [
> (if (odd? number)
> (if (= 0 (mod number 5) :odd-5 :odd)
> (if (= 0 (mod number 5) :even-
On Feb 27, 9:10 pm, reynard wrote:
> This may be more about functional programming in general, rather than
> clojure specific. However, since I mainly use clojure for learning
> functional programming, I would like to discuss it here.
>
> Basically, I can think of the following 2 ways of doing ab
On Feb 25, 12:17 am, joshua-choi wrote:
> When it comes to distinguishing certain types of symbols from other
> things, should one use prefixes or suffixes?
Whichever makes more sense, of course. :)
>
> Example: naming tests with clojure.test/deftest. If you distinguish
> your tests’ symbols at
On Feb 23, 10:47 am, Alfred Tarski wrote:
> Hi,
>
> I have this function:
>
> (defn wrap [x]
> (str "%" x "%"))
>
> and I do
>
> bf=> (str "boo hoo " (map wrap ["fdfd" "ggfs"]))
> "boo hoo clojure.lang.lazy...@9e050eb0"
>
> This looks odd to me, but if the powers that be consider this to be
>
>
> But surely in this case you could do:
>
> (defn print-info []
> (let [[src dst] (dosync [...@source-account @dest-account])]
> (println src)
> (println dst)))
>
> or maybe:
>
> (defn print-info []
> (let [[src dst] (dosync
> (ensure source-account)
>
On Feb 16, 8:27 pm, Yaron wrote:
> Sean and Richard perhaps I can address both of your mails in a single
> go. Here is an example of one of the functions from my calculator:
>
> (defn tax_deductible_expenses
> "The total expenses incurred in business month m that are deductible
> from fe
On Feb 16, 12:26 pm, alux wrote:
> Hello,
>
> the current state of Conway's Prime Machine is athttp://paste.lisp.org/+21BR
Instead of using a quoted list, a vector is more idiomatic in Clojure.
>
> I'l go on learning. The next state should be seperation of print and
> produce. Currently (conwa
On Feb 15, 12:03 pm, Аркадий Рост wrote:
> oh wait...I take a look on binding and with-binding*
> realesation.http://github.com/richhickey/clojure/blob/f4c58e3500b3668a0941ca21f9a...
> Why with-binding* function wasn't write like this:
> (defn with-bindings*
> [bindings f & args]
> (assert-a
On Feb 8, 3:22 am, Stuart Halloway wrote:
> IMO Anything that implements IDeref should adhere to Clojure's vision
> for identity, e.g. reads need to be thread safe, cheap, require no
> coordination, and block no one.
Dereferencing futures or undelivered promises block the dereferencing
thread
On Feb 1, 3:16 pm, Timothy Pratley wrote:
> On 1 February 2010 09:32, Wardrop wrote:
>
> > Could someone step me through the idea behind the -main function
> > (which I've also seen written as just "main" without the hyphen).
>
> Is "-main" special in any way, or is this just a convention that
You should really give paredit.el a go some time. It feels silly to
worry about matching parentheses nowadays.
That aside, I am supportive of any improvement in either compiler or
reader error messages.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
On Jan 24, 6:40 am, CuppoJava wrote:
> Thanks for the reply. That seems to match well with how I thought they
> were supposed to work.
>
> I'm just a little confused by the
> set!, with-local-vars, functions. What are they supposed to be used
> for?
>
> -Patrick
Vars are mutable reference types
On Jan 12, 11:08 am, Gabi wrote:
> What's the idiomatic Clojure way for extracting values/keys from a
> binding form vector [key1 val1 key2 val2..] ?
I suppose that depends on what you want, but:
(apply hash-map keyvals) to make a map or
(map first (partition 2 keyvals)) & (map second (partition
On Jan 6, 2:21 am, Mark Derricutt wrote:
> Is there likely to be a RELEASE version of clojure-contrib 1.1.0 in
> the maven repo to match clojure 1.1.0 at all?
>
> The lack of a release build prevents using the maven release plugin to
> run with any project using it :(
>
> Also - if 1.1.0 is rele
> ((comp negate inc) 6) -> -7
Hm, I was sure negate existed... But seems like it doesn't.
Oh well. (comp - inc) works. :)
--
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
On Dec 11, 11:14 am, ngocdaothanh wrote:
> Because of indents, my previous Clojure code lied to my eyes that x,
> y, f, g are not at the same block level. This is my difficulty with
> Clojure. In short, I can't see a rough algorithm from any Clojure code
> any more just by seeing the shape (leve
Jeff Dik wrote:
> The part "Running code at read-time lets users reprogram Lisp's
> syntax" caught my attention. Is this talking about reader macros? I
> believe I read that clojure doesn't have reader macros, so would it be
> more accurate to say "The whole language is there, _most_ of the
> tim
I just noticed that the API link on the clojure web site brings up
documentation for the master branch of Clojure instead of 1.0.0. I
can't find the 1.0.0 docs anywhere either.
This is obviously a problem for 1.0.0 users, since the docs refer to
features that don't exist.
I think it would be good
On Dec 3, 6:15 am, lazy1 wrote:
> Hello,
>
> I'm trying to create a "factory" method for Java classes, however I'm
> doing something wrong.
>
> (import '(java.util Dictionary HashMap))
>
> (def *containers* { :dict Dictionary :hash HashMap})
> (defn new-container
> [type]
> (new (*containers
On Nov 19, 11:52 am, Gabi wrote:
> This would solve the "holding to the head" problem.
> Many times, lazy-seq would be used without the need to get the same
> cell twice.
> In this case, avoiding cashing would both enhance performance and more
> importantly would avoid OutOfMemoryError Exceptions
On Nov 14, 8:08 pm, gun43 wrote:
> Using r1366 under Win XP.
r1366? From Subversion? That's ancient. Clojure moved to git ages ago;
see
http://github.com/richhickey/clojure
>
> A user defined function:
> 1:27 user=> (defn plus2 [x] (+ x 2))
> #'user/plus2
> 1:28 user=> (plus2 5)
> 7
>
> can onl
On Nov 13, 9:13 am, Krukow wrote:
> I was thinking this may make syntax irregular. I suspect this is a
> deliberate design choice to distinguish clojure protocols from java
> interfaces? Is this the case?
>
As far as I understand it, in defprotocol's case, I suspect there is
no dot because the sp
On Nov 3, 2:03 am, CuppoJava wrote:
> Thanks Brian.
>
> For my own purposes, yes I have no need for a break or return
> statement.
>
> But I'm writing a DSL for others to use. People that don't have
> experience with functional programming, and for them it's easier to
> have a break/return. And
> But whilst this is useful, this doesn't really demonstrate why macros
> are so powerful. Macros are useful because they automatically
> rearrange your source code into something else. They're most similar
> to the Ruby 'eval' function, but operate of data structures rather
> than strings.
>
Nitp
On Oct 19, 5:52 pm, Peregrine wrote:
> Hey I am new to Clojure and I am doing some Project Euler problems to
> help me get started with the language. I've run into a issue I cannot
> seem to get past. I have this code:
>
> (defn findFib
> "Find the sum of all the even-valued terms in the
On Oct 17, 10:32 am, Timothy Pratley wrote:
> > But name is multiply evaluated. This might be preferable:
>
> Hi John,
>
> Could you explain this a bit more for me? I can understand if the
> condition is duplicated that is unnecessary calculation but don't
> appreciate the issue with the binding
On Oct 16, 5:44 pm, Mark Volkmann wrote:
> What's the rule of thumb for deciding whether a function name should
> end with an exclamation point? I thought maybe it was when the
> function modifies its first argument, but it seems there are functions
> that do that and do not have such names.
>
>
On Oct 8, 5:01 am, Allen Rohner wrote:
> Hello, I'd like to announce the availability of a new library, called
> Scriptjure. It's a macro that generates javascript strings from
> Clojure s-exprs. My initial use for it is in glue code for Clojure
> webapps. For example:
>
> (js (fn foo [x]
>
On Oct 1, 9:18 pm, timc wrote:
> (def prx (proxy [IX][]
> (doit
> ([] (doseq [x someSeq] (doit x))
> ([y] (print y
>
> When I tried something of this form, it looks like the call of the 1-
> arg function from the 0-arg function can't be resolved.
>
> Thanks in advance
I'm not cert
On Sep 28, 12:13 pm, Michael Wood wrote:
> Hi
>
> 2009/9/26 gerryx...@gmail.com :
>
>
>
> > (defn float2 [f a b]
> > (f (float a ) (float b)))
>
> > (float2 + 1 2) => 3.0
>
> > (defmacro mfloat2 [f a b]
> > (f (float a) (float b)))
> > (mfloat2 + 1 2 ) => 2.0 ??? macro expend to last expre
On Sep 24, 11:01 am, Miron Brezuleanu wrote:
> Hello,
>
> I find that I tend to name struct instances like the struct. For instance,
>
> (defstruct person :name)
>
> and then
>
> (let [person (struct person "John")]
> )
>
> which breaks further use of (struct person ...) in that let.
>
> Is t
On Sep 22, 3:58 pm, Roman Roelofsen
wrote:
> Hi there!
>
> Lets assume I have this map:
>
> user=> (def person {:name "Father" :childs [{:name "Son" :age 10}]})
>
> Testing:
>
> user=> (-> person :childs first)
> {:name "Son", :age 10}
>
> Now lets filter the child map:
>
> user=> (def only-nam
On Sep 22, 2:23 am, Jung Ko wrote:
> Hi,
>
> Can someone teach me how I can override the "toString" method for a struct ?
>
> Here's a code snippet that shows what I'm trying to do:
>
> user> (defstruct bookinfo :book :filename)
> user> (struct bookinfo "hello" "world") => {:book "hello", :file
On Sep 21, 6:53 pm, patrickdlogan wrote:
> I expected a delay only to be forced by an explicit call to force.
> instead it looks like, being a kind of IDeref, a delay will be forced
> by the REPL.
>
> e.g.
>
> user=> (def del (delay (println "printed") (+ 2 3)))
> #'user/del
> user=> del
> printe
On Sep 21, 4:38 pm, Roger Gilliar wrote:
> I still have some problems to correctly understand the dosync
> semantic. What happens exaclty if two threads try to modify the same
> list:
Nitpick: you're not modifying any lists. :) The only mutating things
are the Refs
>
> Example
>
> thread
> > (def b #^{:b 2} (quote (1 2 3)))
>
> ... and #^{} applies read-time to the following *form* rather than the
> value they evaluate to, so that is why neither (list ...) nor (quote
> ...) work.
Yep. #^ is for read-time metadata. Note though that the following will
work:
(def b '#^{:b 2} (1 2 3)
On Sep 18, 10:52 pm, Patrik Fredriksson wrote:
> Hi!
>
> Could someone please help me understand why the following causes a
> java.lang.OutOfMemoryError: Java heap space for large n:s (10
> works fine, 100 does not).
>
> (def integers (iterate inc 1))
>
> (defn limited-reduce [fn coll n]
On Sep 17, 7:33 pm, Gorsal wrote:
> Basically i need to redefine the meaning of a special form. While i am
> willing to change the name for things like ns to defpackage, i am not
> willing to change the name of forms like apply and defn to achieve my
> goals. Instead, i would like to redefine t
On Sep 15, 6:54 pm, Gorsal wrote:
> I was just wondering about the unwind-protect form, I've heard that it
> doesn't protect against certain types of exits, but what exactly are
> these exits? I've heard return, break, and continue statements said
> but i can't seem to find these statements in c
On Sep 13, 2:43 am, jng27 wrote:
> http://jng.imagine27.com/articles/2009-09-12-122605_pong_in_clojure.html
Neat. I have some suggestions though.
1) I think you use too many refs. the sx, sy, etc. could all be
replaced with a simple
(defstruct position :x :y)
(def whatever (ref (struct p
On Sep 4, 11:22 am, Krukow wrote:
> I was thinking about the capability of changing production systems on
> the fly. E.g. by having an accessible repl in a running production
> system.
>
> If you have a bug in a function, you can fix it by re-def'ing it -
> that is great. However, suppose you wan
Oops, accidentally sent the post before it was ready. Oh, well...
--~--~-~--~~~---~--~~
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
On Sep 3, 3:42 pm, ngocdaothanh wrote:
> Hi,
>
> In Rails you can create a view like this:
>
> my_view.erb:
> <%= "hello" + @name %>
>
> I'm new to Clojure. I want to create something like the above like
> this:
>
> (defn my-view []
> (str "hello" name))
>
> The point is:
> * name is not known
On Sep 3, 9:24 am, Miron Brezuleanu wrote:
> Hello,
>
> I'm a Clojure newbie (many thanks to Rich Hickey and everyone involved
> - it's a great programming environment) and I have some trouble with
> 'eval'.
>
> What I'm trying is:
> $ java -cp clojure.jar clojure.lang.Repl
> Clojure 1.1.0-alpha-
> I'll submit a patch if it's wanted. This would fit in core, or maybe
> contrib.duck-streams with a slightly different name.
This should be in core I think, so that it can work with with-open—
unless we're going to duplicate with-open in contrib. :/
--
Jarkko
--~--~-~--~~--
On Aug 25, 1:47 pm, Dragan Djuric wrote:
> I needed a macro if I wanted to avoid ' in calls. It may seem as
> nitpicking but (to-keyword name) is more readable and less error prone
> than (to-keyword 'name) if I need to use it in lots of places.
If that's all you do, then the easiest approach
On Aug 22, 1:51 pm, jng27 wrote:
> This updated version is 2x as fast as the previous version :
>
> (import 'java.lang.Math)
> (import 'java.math.MathContext)
> (import 'java.math.BigDecimal)
>
> (defn sb-pi [places]
> "Calculates PI digits using the Salamin-Brent algorithm
> and Java's Bi
On Aug 22, 5:56 am, jng27 wrote:
> Took a shot at implementing PI in Clojure using a reasonably fast
> algorithm.
> So why is it so slow ? Is BigDecimal just that bad ? Would fixed point
> arithmetic be better using BigInteger ?
Hmm, my impression is that the java boxed numbers aren't particul
On Aug 16, 12:02 pm, botgerry wrote:
> Hello,all
>
> I'm new to functional programming,want to know how to address nested
> inner seqs in clojure
>
> (def a [[1 2 3 4] [ "ok" "metoo"] [ 5 8 9 ]])
>
> 1: searching in a, if find one inner vector includes number 9 then
> append it a number 13
> [[
Nicolas Oury wrote:
> Dear all,
>
> I try to write a program where I access a java array of non primitive
> and realize aget is very slow.
> (6x slower than the same program with clojure vectors instead of java
> arrays access)
>
> I tried a few combinations of type hints but can't manage to prev
fft1976 wrote:
> On Aug 13, 9:57 pm, Daniel Lyons wrote:
>
> > the code is open source and the techniques for adding
> > optimizations to compilers are well known. So marshall your impulses
> > for the good and we'll all benefit.
>
> It does seem that the optimizations Andy Fingernut did by h
On Aug 14, 10:51 pm, Sean Devlin wrote:
> I'd start with you usage docs
>
> ;; usage:
> ;; (filter-collecting
> ;; (fn [x y] (< x y))
> ;; (fn [x y] (+ x y))
> ;; [1 7 3 9]
> ;; [5 5 5 5])
> ;; ==> (6 8)
;; usage:
;; (filter-collecting < +
;; [1 7 3 9]
;; [5 5 5 5])
;; ==> (6 8)
I'm in favour.
Though, I think that a "def-" would be redundant if the defvar macros
are promoted. Perhaps it would be sensible to keep def as a the
underlying special form and just move in defvar, defvar- and
defmacro-.
I'm not sure whether defonce is useful enough that it should be moved
to co
On Aug 10, 12:41 pm, fft1976 wrote:
> I just uploaded to the group an implementation of the n-body benchmark
> in Clojure (see nbody_init.clj)
>
> http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody〈=j...
>
> My goal was to write a pure-functional version and to avoid any micro-
> opti
On Aug 9, 9:27 am, Chad Harrington wrote:
> Hi all,
> I am learning Clojure and would like to see if there is a better/more
> concise/faster/more idiomatic/etc. way to create the age-index below. My
> version seems awfully roundabout. The basic concept is a toy database table
> stored as a hashm
On Aug 4, 11:08 am, Jonas wrote:
> Hi
>
> I'm playing with the new transient/persistent! features in Clojure. I
> have implemented quicksort as described on wikipedia (http://
> en.wikipedia.org/wiki/Quicksort#Algorithm). Here is the code:
>
> (defn swap-index! [v i j]
> (let [tmp (v i)]
>
On Aug 2, 2:12 am, Meikel Brandmeyer wrote:
>
> (defmacro with-chosen-file
> "Opens a file chooser, binds the result the user chose to the given
> variable name and executes the body. In front of the body there might
> be two options given:
>
> :directory is the initial directory sh
Chad Harrington wrote:
> I have a newbie question about anonymous functions. Why does the first form
> below work and the second form does not?
>
> user> ((fn [] "foo"))
> "foo"
>
> user> (#("foo"))
> ; Evaluation aborted.
fn and #() are not interchangeable. In the first example, you simply
retu
Hi.
I'm not aware of any comprehensive style guide for Clojure. However,
there is a scheme style guide at
http://mumble.net/~campbell/scheme/style.txt
which contains plenty of good advice that applies to Clojure as well.
In addition to the above advice, I have a personal recommendation
regarding
> user=> (macroexpand-1 '(let-coll [a b c] {:a 1 :b 2 :c 3} (println a b
> c)))
> (clojure.core/let [val-fn__23 {:a 1, :b 2, :c 3}
> a (val-fn__23 :a)
> b (val-fn__23 :b)
> c (val-fn__23 :c)]
> (println a
On Jul 15, 1:54 pm, Jan Rychter wrote:
> I've been looking for a function that would take a seq and create a list
> (a real clojure.lang.PersistentList), but haven't found one. The closest
> I got was:
>
> (apply list my-seq)
>
> Essentially, I'm looking for something similar to (vec) that return
On Jul 14, 10:04 pm, bgray wrote:
> I'm not sure if this is a binding issue or not.
>
> user=> (def a 1)
> #'user/a
> user=> (binding [a 3] (filter #(= % a) '(1 2 3)))
> (1)
> user=>
>
> In this case, I was expecting a list with 3 in it.
This is a common gotcha. It's actually a laziness issue: t
On Jul 14, 6:58 pm, Stuart Sierra wrote:
> Namespace-wide fixtures ("once-fixtures") are easy -- they should just
> run around the top-level test function. That's something I can fix,
> and it will be sufficient for your example.
>
> But per-test fixtures ("each-fixtures") present a problem. If
On Jul 13, 1:39 pm, "sailormoo...@gmail.com"
wrote:
> Hi :
>
> I would like to simulate a simple database with the STM of clojure.
> The rules are
> 1. There can be many rooms, and each room has its own attirbute
> 2. One room contains many people, and each person has its own
> attribute
> 3. r
On Jul 11, 6:01 pm, Robert Campbell wrote:
> Hey guys,
>
> I'm just curious why Christophe chose to return seq instead of a str
> for Enlive for his template functions.
>
> Example:
>
> (deftemplate my-page-transformation "index.html" [message style]
> [:style] (content style)
> [:h1] (cont
Shawn Hoover wrote:
> For example, Java doesn't have language support like C#'s using statement
> for executing some block of code and deterministically cleaning up an object
> at the end. You could implement that as a function (in many languages) and
> call it like this:
> (defn do-and-close [o
On Jul 6, 1:26 pm, "philip.hazel...@gmail.com"
wrote:
> On Jul 5, 10:31 pm, Mark Triggs wrote:
>
> > (defn bi-get-pixels
> > [#^BufferedImage bi]
> > (let [raster (.getData bi)
> > pixels (.getPixels raster 0 0 (.getWidth bi) (.getHeight bi)
> > (cast (Cl
1 - 100 of 123 matches
Mail list logo