I have a vector that I need to count the size of and do a simple math
calculation with.
Say for example:
(defn vect1 [1 2 3 4])
Typing (count vect1) returns the size of 4 that I need. I thought that
I could simply use (count vect1) in an a simple infix expression, ie:
(* (count vect1) 5)howev
Jeff Gross wrote:
> I have a vector that I need to count the size of and do a simple math
> calculation with.
> Say for example:
> (defn vect1 [1 2 3 4])
>
> Typing (count vect1) returns the size of 4 that I need. I thought that
> I could simply use (count vect1) in an a simple infix expression, i
Hi Jeff, you're using defn which defines a function instead of def
which defines a var;
(def vect1 [1 2 3 4])
#'user/vect1
user=> (* (count vect1) 5)
20
Rgds, Adrian.
On Mon, Sep 14, 2009 at 8:05 AM, Jeff Gross wrote:
>
> I have a vector that I need to count the size of and do a simple math
>
Alternatively, if really meant to use defn then it should have been;
(defn vect1 [] [1 2 3 4])
#'user/vect1
user=> (* (count (vect1)) 5)
20
On Mon, Sep 14, 2009 at 2:28 PM, Adrian Cuthbertson
wrote:
> Hi Jeff, you're using defn which defines a function instead of def
> which defines a var;
>
>
On Sun, Sep 13, 2009 at 7:09 PM, Richard Newman wrote:
>
> Thought I'd share with the group. Clojure's sets are fast!
>
> http://www.holygoat.co.uk/blog/entry/2009-09-13-1
Nice writeup!
...and I hate to be picky, but you can probably compare
strings sizes using a faster mechanism than the examp
I'm happy to inform everyone of the Conjure 0.2 release. Check it out
at: http://github.com/macourtney/Conjure
Download the jar at: http://github.com/macourtney/Conjure/downloads
Conjure is a Rails like framework for Clojure. The new version of
Conjure has many new features including:
* The Rin
On 14 Wrz, 06:01, Richard Newman wrote:
> (...)
> Possibly it's just that your ns doesn't match up to the source path
> (examples versus example).
Nope, it's not that easy. I changed "clojure.example.hello" to
"clojure.examples.hello" in the hello.clj file, and the message was
still the same.
(defn func [arg] (println "func: " arg))
I'd like to invoke 'func' using the string name of the function,
something like:
("func" "mytag")
Obviously, this would be answered with "java.lang.ClassCastException:
java.lang.String cannot be cast to clojure.lang.IFn"
I need to find a way to convert t
Hello,
one possibility:
1:15 user=> (defn func [arg] (println "func: " arg))
#'user/func
1:16 user=> ((ns-resolve *ns* (symbol "func")) "laurent")
func: laurent
nil
1:17 user=>
HTH,
--
Laurent
2009/9/14 wireless
>
> (defn func [arg] (println "func: " arg))
>
> I'd like to invoke 'func' usi
> Nice writeup!
Thanks!
> ...and I hate to be picky, but you can probably compare
> strings sizes using a faster mechanism than the examples you
> gave.
Yeah, I figured I must have been doing something wrong, but I thought
I'd leave it out there as a bit of ethnographic research :)
> So now
Hi Matt,
This is a good start! Since you are only at 0.2, any chance I can
convince you to target Clojure 1.1 and later only, and switch to using
clojure.test (the replacement for clojure.contrib.test-is)?
If you are willing, I will make the switch on my fork and issue a pull
request.
Stu
2009/9/14 TPJ :
>
> On 14 Wrz, 06:01, Richard Newman wrote:
>> (...)
>> Possibly it's just that your ns doesn't match up to the source path
>> (examples versus example).
>
> Nope, it's not that easy. I changed "clojure.example.hello" to
> "clojure.examples.hello" in the hello.clj file, and the me
> Nope, it's not that easy. I changed "clojure.example.hello" to
> "clojure.examples.hello" in the hello.clj file, and the message was
> still the same. (Hard to believe, isn't it?)
What's the value of *compile-path*? Is it in your classpath?
--~--~-~--~~~---~--~
> Much of the semantics of the query language is based on Prolog.
as an aside, i was under the impression that Datalog was syntactically
a subset of Prolog, but was not semantically so much so, since in
Prolog order matters e.g. wrt termination.
sincerely.
--~--~-~--~~~-
Matt,
There's a missing double quote on line 11 of lancet.sh. After adding
that, I had no problem compiling Conjure. Looking forward to trying
it.
Jim
On Mon, Sep 14, 2009 at 9:49 AM, Matt wrote:
>
> I'm happy to inform everyone of the Conjure 0.2 release. Check it out
> at: http://github.com/
I put an update in my original post, and I also (like you) timed
without the side effects I'd inserted (empty-string print statements).
Unlike your code, I'm using non-constant strings, which might explain
the difference.
I note:
The 1,000 string length comparisons take 0.184ms; the negative set
I am starting to write a large web application using Clojure and
Compojure and am running into some design trouble while designing my
data model. To illustrate my problem I am going to make up some fake
data. Suppose you are writing an Insurance application which has the
tables Policy, Person and
I think that you made the mistake in the first step: you cannot
*change* a clojure's map. Thus, you cannot change one particular
"snapshot" of person's data. No problem up to this point. You can only
create a new map with some data reused. There lies the problem - how
to "update the references" to
We mainly use macros to create functions to deal with associations,
a bit like ActiveRecord except that it is not yet as dynamic. We do not
use the table meta data to find the associations
and create the finders, etc...
We want eventually to add stuff to clj-record to make it more like
ActiveRecor
Hi Brenton,
Nested maps are a good way to start, but they're pretty low level as
you want to do more complicated things. If you're talking about data
associations, the relational model is higher level and it's really
worth modeling your data in that way.
Relational data manipulation doesn't requ
Hello, I'm new in clojure and lisp, and I have problem with making
this code elegant (or at least short).
This is Floyd-Warshall algorithm - very simple algorithm in imperative
form (3 nested for loops).
In clojure the best I've get so far is this monstrosity:
(defn create-graph [nodes distance
On Aug 30, 7:14 am, CuppoJava wrote:
> Hi Elliot,
> I've written a small game using Clojure and LWJGL, and I've run into
> the exact same issue (balancing between mutability and immutability)
> when I was working on it. The three approaches I tried were:
First of all, thanks for your input; I'm
Hi Brenton,
I think the simplest solution to this problem is to use functions
instead of maps. That is, instead of defining your API in terms of
maps with specific keys, define it in terms of functions that read/
write individual fields.
For example, you would have an opaque "Person" object, pe
Woah formatting! :-)
This is just a formatting cleanup...
Mostly I pressed ctrl+alt+q in emacs.
I also removed some commas and made things more uniform in a couple
places
---
(defn create-graph [nodes distances]
{:nodes nodes :distances distances})
(defn processed [k i j D P]
(le
Did you also read the overview that's part of contrib at
http://richhickey.github.com/clojure-contrib/doc/datalog.html.
I don't know if you already saw that, but since you didn't mention it,
I thought I'd be sure.
Tom
On Sep 12, 6:53 pm, Robert Luo wrote:
> Thank you Josh for your answer.
>
>
Hello,
On Mon, Sep 14, 2009 at 11:48 PM, ajuc wrote:
>
> Hello, I'm new in clojure and lisp, and I have problem with making
> this code elegant (or at least short).
>
> This is Floyd-Warshall algorithm - very simple algorithm in imperative
> form (3 nested for loops).
>
> In clojure the best I'v
On Mon, Sep 14, 2009 at 10:02 PM, Tom Faulhaber wrote:
>
> Did you also read the overview that's part of contrib at
> http://richhickey.github.com/clojure-contrib/doc/datalog.html.
>
So because of this thread, I just went and perused the description of
the Clojure datalog library.
Some things I
27 matches
Mail list logo