In general, I find that multiple arguments types for a function confusing.
If dotimes is going to take multiple types it should be a multifn. That
seems to imply a performance hit.
I think Clojure wisely does not (or rarely does not?) allow for multiple
types to be passed into a function.
On top o
I agree that this is initially confusion, but I think that if you spend more
than a couple of days with Clojure you will understand the ubiquitous and
liberal use of binding forms.
On Sun, Feb 22, 2009 at 2:42 PM, Mark Volkmann wrote:
>
> On Sun, Feb 22, 2009 at 1:34 PM, David Nolen
&
Interesting thread on LtU on this subject:
http://lambda-the-ultimate.org/node/1646
On Mon, Feb 23, 2009 at 10:42 AM, Mark Volkmann
wrote:
>
> I have an idea I'd like to float to see if there are reasons why it's
> a bad idea.
>
> What if Clojure had an alternate "surface" syntax that was transla
On Mon, Feb 23, 2009 at 12:10 PM, Mark Volkmann
wrote:
> The parens don't bother me. My concern though is that many people
> won't take the time to learn Clojure primarily because of the parens.
> The preprocessor would appease those people and not change anything
> for those that like Clojure jus
Is this supported yet? M-. is supposed to handle this, but I get an error
when I try.
David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegroups.co
(time (let [arr (make-array Float/TYPE 1 1)]
(dotimes [_ 10]
(let [#^floats sub-arr (aget arr 0)]
(aset-float sub-arr 0 0.0)
Seems to work? Looks an eligible candidate for a macro.
On Mon, Feb 23, 2009 at 9:04 PM, Jason Wolfe wrote:
>
> I'm trying to call some third-party code th
You're right, works perfectly on clojure sources, but not the instances
you've described. It would be great if this would work again. I don't
understand swank/slime well enough to try it myself.
On Mon, Feb 23, 2009 at 9:23 PM, Alec Berryman wrote:
>
> David Nolen on 2009
>
> 1) User-friendly printing.
>
> I implement the multimethods print-method and print-dup for my
> classes, which allows me to specify how objects are printed. print-
> method and print-dup dispatch on class, so my types need to be
> classes or at least derive from a class that is distinct from th
That should work fine as far as I can tell.
On Wed, Feb 25, 2009 at 3:36 PM, Jeffrey Straszheim <
straszheimjeff...@gmail.com> wrote:
> If in namespace one I define
>(defmulti fred dispatch-fred)
>
> and have imported that ns into another, can I just do
>
> (defmethod fred ::val [x] )
25, 2009 at 7:51 PM, Rich Hickey wrote:
>
>
>
> On Feb 25, 12:19 pm, Konrad Hinsen wrote:
> > On Feb 25, 2009, at 17:40, David Nolen wrote:
> >
> > > Should print and println be multimethods? It seems the ability to
> > > custom print a data structure
What about something like:
(defn gt [str1 str2]
(first (sort [str1 str2])))
(gt "Zoe" "Bob") ; -> "Bob"
On Fri, Feb 27, 2009 at 12:03 PM, Phil Hagelberg wrote:
>
> Christian Vest Hansen writes:
>
> >> Are you referring to using <, >, =, with objects that implement
> >> java.lang.Comparable?
Remember that you can force lazy sequences if you need to as you are with
doseq with doall (retains head) and dorun (does not) as well.
You probably want
(dorun (map #(add-watch % watcher callback-fn) all-agents))
I think it's pretty clear here what's going on. Your code needs
side-effects. In C
I appreciate that they stand out. Again, this is similar to the constants
conversation earlier, visually marking the intended use is a good habit,
IMHO. Of course this doesn't mean that error-kit should define the base
error this way, but I intend to keep on wrapping my errors in earmuffs :)
Davi
capitals seems pretty weird for a Lisp. Now that I think about it, perhaps
foo-error isn't so bad.
David
On Tue, Mar 3, 2009 at 10:54 PM, Chouser wrote:
>
> On Tue, Mar 3, 2009 at 10:36 PM, David Nolen
> wrote:
> > I appreciate that they stand out. Again, this is simila
Depending on what you are doing perhaps you could use (hash x). This might
not be very helpful if you need to update keys frequently. However if
you're mostly doing lookups, then this would help quite a bit.
On Sat, Mar 7, 2009 at 3:44 PM, Mark Engelberg wrote:
>
> Here's why it would be useful t
Structs are maps with shared keys and positional constructors as Rich
mentions in the original post. I think Rich is saying that maps should
indeed "be abused" ;) By building all "higher level" structures on top of
them, consumers are guaranteed not only your custom functionality, but all
the func
The first regex is returning an empty list not nil.
David
On Mon, Mar 9, 2009 at 11:48 AM, timc wrote:
>
> Can someone please see what's wrong with this.
>
> (defn getArg [arg]
>"Return a [keyword value] depending on the form of the string arg:
>1. arg is of the form +x ==> [:x t
It does. Also Practical Common Lisp and On Lisp cover this in depth as well,
though you'll need to convert commas into tildes as well as use ~' for each
level of backquote depth that you don't want Clojure to namespace free
symbols.
On Tue, Mar 10, 2009 at 6:05 PM, .Bill Smith wrote:
>
> Does the
Practical Common Lisp and On Lisp are available online and free.
On Tue, Mar 10, 2009 at 6:16 PM, David Nolen wrote:
> It does. Also Practical Common Lisp and On Lisp cover this in depth as
> well, though you'll need to convert commas into tildes as well as use ~' for
> each
Doesn't error-kit do this?
On Wed, Mar 11, 2009 at 10:15 PM, Mark Engelberg
wrote:
>
> I'm thinking about implementing a backtracking mechanism that throws
> errors as a way to escape out of the current computation and try
> another possibility. I'd want to create a specific error to escape,
> a
Amazing stuff. In particular this finally makes debugging macros sane.
For those of you that are using swank-clojure you only need to make minor
modifications to swank-clojure to pretty-print your macro expansions to the
macro expansion buffer. Even better you can move the cursor to subform
macros
So that people can copy and paste the change in basic.clj
(defn- apply-macro-expander [expander string]
(binding [*print-suppress-namespaces* true]
(let [astr (with-out-str
(with-pprint-dispatch *code-dispatch*
(pprint (expander (read-from-string string)]
(subs astr 0 (dec (cou
I suppose the following is more idiomatic:
(defn- apply-macro-expander [expander string]
(let [astr (with-out-str
(binding [*print-suppress-namespaces* true]
(with-pprint-dispatch *code-dispatch*
(pprint (expander (read-from-string string))]
(subs astr 0 (dec (count astr
s-namespaces* true]
>(with-pprint-dispatch *code-dispatch*
> (write (expander (read-from-string string)) :pretty true :stream
> nil
>
> Completely untested! :-)
>
> Tom
>
> On Mar 12, 11:07 am, David Nolen wrote:
> > I suppose the following is more idiomatic:
&
On Mon, Mar 16, 2009 at 3:42 AM, Tassilo Horn wrote:
>
>
> When adding ~/.clojure/ to `swank-clojure-extra-classpaths' and starting
> SLIME, htop shows that this directory is not in the -cp java option.
> Sending a SIGINT kills the clojure process and doesn't interrupt the
> current Thread only...
This has come up before. You can actually work around this (search the
mailing list for declare)
I think that when not hacking against the REPL that the default behavior is
a good one. Having to use declare bugged me a little at first, but I now
consider it a very minor annoyance compared to the ad
lare because this came up in another thread about
declare and someone had hacked the reader to not bail immediately on
undefined symbols).
In CL, if you have definitions out of order in the compiler will issue
warnings.
>
> I'm not saying it's an easy change...
>
>
>
Here's the post by Timothy talking about patching the compiler:
http://groups.google.com/group/clojure/msg/ef5bae605f4a0730
On Mon, Mar 16, 2009 at 4:36 PM, Paul Stadig wrote:
> On Mon, Mar 16, 2009 at 4:18 PM, David Nolen wrote:
>
>> On Mon, Mar 16, 2009 at 4:08 PM, P
I'm mostly a front-end UI person with crazy amounts of JS experience so most
of my input will be from that stand point.
1. I agree with Sean on this one. No need to bring in middleware that can't
be expressed in 10X-20X less code in pure Clojure.
2. The framework should allow for any backend (even
Doesn't On Lisp talk about simulating CLOS with closures? It's free online.
I would like to add as the creator that I would not use Spinoza yet ;) And
I've put it on hold as I'm currently obsessed with trying to port cl-cont.
Spinoza still needs quite a bit of work, I started on that before a few
You can get it here:
http://github.com/swannodette/clj-cont/tree/master
So over the past week I've been porting cl-cont (
http://common-lisp.net/project/cl-cont/) originally written by Slava
Akhmechet to Clojure. I've now ported most of the functionality that's
translatable from Common Lisp though
This works well as long as you don't mind the perf hit for the second
dispatch :)
On Fri, Mar 20, 2009 at 11:35 AM, Paul Stadig wrote:
> You could use multiple multi-methods:
>
> user=> (defmulti plus-int (fn [x y] (type y)))
> #'user/plus-int
> user=> (defmethod plus-int :default [x y] (println
Congrats! It's been said many a time, but it bears being said again, Clojure
makes hacking fun again. It's great working with a language that is very
production ready, yet still evolving at a quick clip. It's also fascinating
that a language supports so many different usage patterns- the diversity
I'm wondering if it's possible to create a Clojure function that does what
the dot operator does. It seems like this would be possible with definline
but I'm unable to get this to work or figure it out. For example I want to
be able write something like the following:
(dot "Hello world" (list 'sub
On Sat, Mar 21, 2009 at 9:10 PM, Kevin Downey wrote:
>
> you want defmacro not definline. the result of a macro is a data
> structure. that data structure is then evaluated in place of the call
> to the macro. definline (I think?) behaves similar to a function, so
> if it returns a data structure
Or rather I did not express that requirement clearly enough.
On Sat, Mar 21, 2009 at 9:21 PM, David Nolen wrote:
> On Sat, Mar 21, 2009 at 9:10 PM, Kevin Downey wrote:
>
>>
>> you want defmacro not definline. the result of a macro is a data
>> structure. that data str
Thanks all for the pointers, this looks like a workable approach. In my
case I'm not bothered by the performance hit from reflection (CPS
transformation creates an obscene number of anonymous functions anyway).
However I am running into an issue. Here's my dot function:
(def not-seq? (comp not se
That was it! At one point I knew these things. Thanks much.
On Sun, Mar 22, 2009 at 2:18 PM, Eric Tschetter wrote:
>
> > (let [myref (ref {})]
> > (dot
> >clojure.lang.LockingTransaction
> >(list 'runInTransaction (fn [] (commute myref assoc :mykey :myval)
> > I'm getting a instanc
s are being transformed into a version that
relies on reflection you can't expect this code to be super performant.
That may or may matter depending on your use case ;)
On Sun, Mar 22, 2009 at 5:28 PM, David Nolen wrote:
> That was it! At one point I knew these things. Thanks much
You could always build something where setters/getters are auto-magically
created if specified by the constructor macro. And with clojure.contrib.def
you could auto-magically generate private setters/getters.
On Mon, Mar 23, 2009 at 4:27 AM, Mark Engelberg wrote:
>
> I've been thinking quite a bi
You need to make sure all the different moving parts are based on the newest
version of Clojure as well. This includes swank-clojure, clojure-mode, and
any other libs you might be using.
On Mon, Mar 23, 2009 at 9:51 AM, Dan Pomohaci wrote:
>
> Hi,
>
> When I start slime with the new clojure_20090
Looks interesting and maybe even very useful. Why not put your code on
Github or some other public repo of your liking. It's much nicer than
pasting all this code ;)
On Mon, Mar 23, 2009 at 9:18 PM, Sean wrote:
>
> Hello Everyone,
> I've been reviewing the str-utils package, and I'd like to prop
The latest version of Clojure incorporated lazy sequences which broke many
libraries early on. Most of these problems have been worked out. In my
experience you should use the cutting edge version of everything including
SLIME. I clone everything from GitHub (clojure, clojure-contrib,
swank-cloju
Javadoc would be nice, but I do note that Rich's Java code is pretty darn
clear ;)
I also note the indentation style is similar to Whitesmith's according to
Wikipedia http://en.wikipedia.org/wiki/Indent_style. I've always preferred
the BSD curly brace level matching convention over the K&R derivat
For what it's worth I'm a big fan of the wishful thinking programming style.
I write some functions how I think they should look, declare the functions I
haven't defined yet. Then I implement the lower level functions, write some
tests- then usually the higher level stuff works without too much twe
Your solution is the accepted one ;)
On Sat, Mar 28, 2009 at 1:59 PM, ke...@ksvanhorn.com wrote:
>
> I'm in the process of learning Clojure, and I ran across something
> that other newbies like me may find useful. The question I had was
> this: how does one get a method name into a macro? Cons
On Sat, Mar 28, 2009 at 4:40 PM, mikel wrote:
>
> So, at minimum, to make a solid port, you need to add a function that
> can return a sensible type value for any input
Enjoying the thread. Out of curiosity for which Clojure values is the return
value of the type function undefined?
David
--~
Having thought a little about multiple inheritance when implementing Spinoza
I also ran into this problem. However at the time I wasn't hindered by
multifn dispatch as much as the fact that parents cannot be ordered (because
calling parents on a tag returns a set) as pointed out by Mark. I understa
Here's a quickly hacked together solution (code golf welcome), I'm using
special variables so that we don't affect what other multimethods see:
(def *super* nil)
(defmacro super [afn obj & args]
(let [fn-key (keyword (str afn))]
`(binding [*super* {~fn-key (or (and (~fn-key *super*)
(fi
very cool :)
On 3/28/09, Stuart Sierra wrote:
>
> Hi folks,
> I finally came up with fixtures for clojure.contrib.test-is. Now you
> can do before/after setup for each test case. Here's the
> documentation, let me know what you think.
> -Stuart Sierra
>
> ;; FIXTURES (new)
> ;;
> ;; Fixt
On Sun, Mar 29, 2009 at 1:25 AM, mikel wrote:
>
> (type (proxy [clojure.lang.IMeta clojure.lang.IRef][]))
>
> java.lang.UnsupportedOperationException: meta (NO_SOURCE_FILE:0)
> [Thrown class clojure.lang.Compiler$CompilerException]
>
>
> No doubt someone is going to point out that the proxy objec
Glad to be of help. To be totally honest I hadn't really tested it too much,
so I don't know ;) One obvious limitation here is that it doesn't work with
multiple inheritance (it only looks at the first item in the parents set).
As long you're sticking with a Java-style single inheritance model thi
n the technical sense :) case as the one you've pointed out?
I'm interested in hearing reasons if there is one.
David
On Sun, Mar 29, 2009 at 5:22 PM, mikel wrote:
>
>
>
> On Mar 29, 1:34 am, David Nolen wrote:
> > On Sun, Mar 29, 2009 at 1:25 AM, mikel wrote:
> >
There's a few posts on the mailing list suggesting some good starting
points. You can get far in Clojure without resorting to Java but it
definitely helps to know some if you really want to advance your knowledge
of Clojure's inner workings as well as get it to interoperate with Java
libraries.
O
Did you try using aset-int instead of aset?
On Tue, Mar 31, 2009 at 8:25 AM, Vincent Foley wrote:
>
> For those interested, I managed to improve the performance of my
> original program from 2 minutes 40 seconds to decode 1000+ files down
> to 2 minutes. I'm still far from my goal, but it's an
Many thanks for the long and reasoned reply (and to mikel as well for adding
his thoughts). I apologize for my slowness in understanding the nature of
multimethods- it's tricky converting my existing knowledge ;)
On Tue, Mar 31, 2009 at 10:32 AM, Rich Hickey wrote:
>
>
> Here are the areas I'm lo
> >
> > > No, but in my defense I did not know such a function existed :) I'll
> > > give it a whirl and report back!
> >
> > > On Mar 31, 9:57 am, David Nolen wrote:
> > > > Did you try using aset-int instead of aset?
> >
> >
1 Class loader
> 0.0% 2 Unknown: no last frame
>
>
> Flat profile of 0.01 secs (1 total ticks): DestroyJavaVM
>
> Thread-local ticks:
> 100.0% 1 Blocked (of total)
>
>
> Global summary of 176.12 seconds:
> 100.0% 1160
Foley wrote:
>
> I tried it just now; it made no difference. Nevertheless, thank you
> for you help and time!
>
> On Mar 31, 9:38 pm, David Nolen wrote:
> > Did you try
> > (int (mask8 (. buf__2572__auto__ (get
> >
> > ?
> >
> > Your ma
As as a side note, putting type hints into the body of the macro expansion
doesn't do anything. These will be discarded. You will need to coerce types
via other methods, investigating how ints is implemented in core.clj is a
good place to start.
On Tue, Mar 31, 2009 at 11:04 PM, David Nolen
comp creates a new function that you can store.
-> threads a value through a series of expressions.
On Wed, Apr 1, 2009 at 12:52 AM, kkw wrote:
>
> Hi folks,
>
>I have some code where I wanted to:
> - take a list of stuff (which includes another list inside)
> - use 'seq-utils/flatten' to fl
Very cool.
On Wed, Apr 1, 2009 at 8:47 AM, Rich Hickey wrote:
>
>
> I've added get-method (SVN 1338).
>
> (derive ::Circle ::Shape)
> (derive ::Rect ::Shape)
>
> (defmulti area :Shape)
>
> ;note - you can name methods
> (defmethod area ::Shape area-shape [x] nil)
>
> (get-method area ::Rect)
> #
On Apr 1, 11:41 am, Chanwoo Yoo wrote:
> Hello. Yesterday, I talked with a representative of a publisher about
> a translation of Lisp books. There are books about Ruby, Lua, Erlang,
> and Groovy in South Korea, but there is no book about Lisp except
> SICP. So he is considering printing the fi
you should look into float-array and friends.
On Fri, Apr 3, 2009 at 12:04 AM, Sean wrote:
>
> I'm working with AWT, and there is a method that requires a float[]
> (The java.awt.BasicStroke constructor). Is it possible to directly
> create an array of primitives directly in Clojure, or do I ne
I think what you want is:
(def foo (ref 0))
(defn square [x] (* x x))
(defn square-ref [x] (dosync (ref-set foo (square x
(square-ref 2)
On Mon, Apr 6, 2009 at 3:02 PM, bgray wrote:
>
> I have a some what (I believe) easy question. Could someone let me
> know what I'm doing wrong? A simpli
Congrats!
Perhaps soon there should be a Projects Using Clojure section on the main
site?
Good way to get the word out that people are using Clojure in the "real
world"
David
On Tue, Apr 7, 2009 at 10:47 AM, Sean wrote:
>
> Okay wow... it'll take some time to fully appreciate this.
>
> Can yo
Very exciting, thanks for the excellent and informative writeup.
On Wed, Apr 8, 2009 at 12:41 AM, John D. Hume wrote:
>
> As predicted, Google has now released Java support for AppEngine. I
> was lucky enough to get an early look, which I dedicated entirely to
> Clojure.
>
> Here's a writeup:
> h
This is great. I had thought that supporting some kind of partial template
thing would be interesting, but that's actually just my poor logic at work
;)
It seems like with the new version of Enlive I could do something like this:
(deftemplate pageA-template path
[]
[[:div (attr? :tiptree:repl
Real quick thought:
(deftemplate-generator template-generator
[args]
rule-vector transform-fn)
Would produce a template generator.
(def template-name (template-generator path-to-xml-or-file-or-xml-string))
Would produce a real template.
(apply str (template-name arg1 arg2 arg3))
--~--~
Using try-catch for control flow is probably not a good idea. Shameless
plug, do you think you could get this to work with clj-cont? clj-cont is a
port I did of cl-cont. It has some limitations, but because Clojure has so
few special forms (compared to Common Lisp), it has the chance to achieve
pre
retty
much anything else.
However, with some quick testing I note that using Exceptions for flow
control might be even 2x slower than clj-cont.
On Mon, Apr 13, 2009 at 1:54 PM, David Nolen wrote:
> Using try-catch for control flow is probably not a good idea. Shameless
> plug, do you thi
27;re throwing away the away stack trace
making debugging more difficult? It got me thinking about arbitrary flow
control, on the nested loop thread I've added my findings...
On Mon, Apr 13, 2009 at 4:24 PM, Victor Rodriguez wrote:
>
> On Mon, Apr 13, 2009 at 2:13 PM, David Nolen
> wrote
Out of simple curiosity I wondered how hard it would be to implement flow
control using proxy. I know Rich isn't hot on non-structured programming,
but there may be times where this might be useful:
(ns flow.return-from
(:import (flow IReturnFrom)))
(defn create-return-from
[value]
(proxy [T
Do you have any plans for continuing to support this? If so are you against
putting this on GitHub or Google Code so that people can follow it's
development?
Thanks for contributing it to the community.
On Wed, Feb 25, 2009 at 7:49 PM, jim wrote:
>
> I've just uploaded a javascript generator ala
ce maps are not
ordered.
On Tue, Apr 14, 2009 at 1:19 AM, David Nolen wrote:
> Do you have any plans for continuing to support this? If so are you against
> putting this on GitHub or Google Code so that people can follow it's
> development?
> Thanks for contributing it to the c
Cool! Rather then waiting, you could host it in the interim on GitHub or
Google Code so people like myself can submit patches (which I'm more than
willing to do) ;) Just a thought...
A couple of things:
(println
(javascript (var x)))
I would expect this to convert to:
var x;
It does not.
(pri
Cool! Rather then waiting, you could host it in the interim on GitHub or
Google Code so people like myself can submit patches (which I'm more than
willing to do) ;) Just a thought...
A couple of things:
(println
(javascript (var x)))
I would expect this to convert to:
var x;
It does not.
(pri
Joda Time, Colt, Fork/Join seem like projects that truly add something to
Clojure. These are projects which solve problems that developers have come
to expect from their respective language.
Joda Time - sane date/time (really useful when building web services).
Colt - enough people want to do graph
s over and over again (writing
matrix math Clojure apps on top of Clojure vectors...)
On Tue, Apr 14, 2009 at 11:01 AM, David Nolen wrote:
> Joda Time, Colt, Fork/Join seem like projects that truly add something to
> Clojure. These are projects which solve problems that developers have come
&
Cool! Thanks.
Also sorry for the accidental double post and I had a typo, I meant the
weird result was:
(println
(javascript (new ClassGenerator {prop1 "a" prop2 "b"})))
> var MyClass = new(ClassGenerator, {prop1:"a",prop2:"b"});
Instead of-
var MyClass = new ClassGenerator({prop1:"a", prop2:"b
Great! I will play around with the new features and returns with some more
informed feedback ;)
On Tue, Apr 14, 2009 at 9:58 AM, Christophe Grand wrote:
>
> Hello David,
>
> David Nolen a écrit :
> > Considering the above, I'm left wondering if it's possible to
there right
now ;)
On Tue, Apr 14, 2009 at 1:31 PM, Christophe Grand wrote:
>
> I pushed do->, attr=, attr? and snippets values as source to github
> http://github.com/cgrand/enlive/commits/right
>
> Christophe Grand a écrit :
> > Hello David,
> >
> > David Nolen
e:
>
> I pushed do->, attr=, attr? and snippets values as source to github
> http://github.com/cgrand/enlive/commits/right
>
> Christophe Grand a écrit :
> > Hello David,
> >
> > David Nolen a écrit :
> >
> >> Considering the above, I'm left wo
Because predicates in selectors no longer need to be quoted it seems you
can't use Enlive selectors in a first class way with snippets:
(let [aselector [[:div (attr= :tiptree:widget "widgetA")]]]
((snippet "widget.html" aselector
[some-map]
[:div.value] (content "foo")) {}))
I believe th
pp6 {:widgetA {:value "0"},
:widgetB {:value "1"}}))
Works for me, and this was in general the use case I was thinking of.
On Thu, Apr 16, 2009 at 4:24 PM, David Nolen wrote:
> Because predicates in selectors no longer need to be quoted it seems you
> can't use E
]
>> [widget]
>> [:div.value] (content (if widget
>> (:value widget)
>> "foo")))
>>
>> (deftemplate my-app6 "app2.html"
>> [widgets]
>> [[:div (attr?
If you have the latest version of clojure.contrib you can do the following:
Modify the namespace declaration in swank-clojure/swank/commands/basic.clj
to look like the following:
(ns swank.commands.basic
(:refer-clojure :exclude [load-file])
(:use (swank util commands core)
(swank.util
include sub-forms.
> I will keep digging...
>
> Thanks again,
> Paul.
>
> 2009/4/17 Jeffrey Chu :
> >
> > Thanks for the tip. I've added it to swank-clojure (only if you have
> > clojure.contrib installed though, so don't forget to have that
> >
You have two other function calls
getAdaptedWeightVector
computeActualResponse
Are these recursive as well?
On Sun, Apr 19, 2009 at 11:26 PM, jleehurt wrote:
>
> Hi all, I have the following code that trains a perceptron with the
> given inputs and corresponding desired inputs. For input/output
A couple of things. In your initial example, you conflated some things. One
issue is simply a matter of convenience- defining a getter so that you can
use Python object property access (via the dot operator). Personally I don't
like this idiom at all (you find it in Objective-C 2.0 and Javascript).
Maps aren't ordered so this isn't a good idea anyway.
The reason first/second work is because they call seq on the collection.
(key (nth (seq {:a 1 :b 2 :c 3}) 1)) -> :b
On Mon, Apr 20, 2009 at 2:51 PM, hughw wrote:
>
> Hi all,
>
> Why should 'first and 'second work on maps, but not 'nth?
>
> u
Konrad added an early implementation of abstract data types to
clojure-contrib (types.clj) you might want to check that out.
I also did some work on supporting more traditional style OO with Spinoza
(structural+behavioral inheritance), but I've sidelined it for the time
being until I find that I ac
Nice post thanks for putting it together. My gut feeling is that the need
for information hiding is still overinflated, but... until someone builds a
200k LOC Clojure program who will know for sure?
Here's my shot at a solution for private data:
(defn set-private [m k x]
(let [the-meta(meta
On Mon, Apr 20, 2009 at 5:17 PM, Hugh Winkler wrote
>
>
> Thanks! I think 'nth ought to behave just like 'first and 'second,
> don't you? If it's a good idea for 'first it's a good idea for 'nth.
>
It does seems like a reasonable behavior for sorted-set and sorted-map, but
what else really? Also
nse? A few quick tests show that the hash of a data structure will
match on any VM.
On Wed, Apr 22, 2009 at 1:01 PM, Victor Rodriguez wrote:
>
> On Tue, Apr 21, 2009 at 12:01 PM, David Nolen
> wrote:
> > Nice post thanks for putting it together. My gut feeling is that the
> need
&
[m k]
(get (:private (meta m)) k))
(defn eq? [a b]
(and (= a b)
(= (:private (meta a))
(:private (meta b)
On Wed, Apr 22, 2009 at 7:20 PM, Victor Rodriguez wrote:
>
> On Wed, Apr 22, 2009 at 1:28 PM, David Nolen
> wrote:
> > You're missing the clever hack ;
On Fri, Apr 24, 2009 at 12:15 PM, Mark Engelberg
wrote:
>
> The problem, of course, is that there is a language design principle
> that has evolved in the OO community that client code shouldn't need
> to know whether you are accessing a field or a method. In Clojure,
> things kind of break down
Oops didn't finish my thought before sending. Anyways, the point is that
Clojure encourages the programmer to design functionality around functions
not data structures. Because Clojure is a Lisp, this syntax can be very
expressive.
On Fri, Apr 24, 2009 at 12:49 PM, David Nolen wrote:
>
Well you have it in your local repo, that "counts" ;)
In fact that is the big advantage of a DVCS, that you can make local
commits. This also means that if for some reason the big server in the sky
goes down, your repo has all the information that the big sky one did and
can be used by anyone to c
Perhaps I'm being dense but I still fail to see what the issue is here:
(defn setter [sym]
`(defn ~(symbol (str "set-" sym)) [~'x ~'y]
(assoc ~'x ~(keyword (str sym)) ~'y)))
(defn getter [sym]
`(defn ~(symbol (str "get-" sym)) [~'x]
(~(keyword (str sym)) ~'x)))
(defmacro accessors [
101 - 200 of 2147 matches
Mail list logo