On 2/21/15 4:57 AM, Cecil Westerhof wrote:
I want to work with default values. For this I use:
[& nr]
This gives the value null to nr. So far so good.
But I want to propagate the value, because I want to fill the default at a
higher level.
I have:
(defn test-lucky-numbers
problem is that the function also accepts two
parameters. (I understood optional parameters wrongly.) I should probably
go back to my first option of a multi-arity function.
Would a be possibly to define a value that is only known in the local
source file?
> On Sat Feb 21 2015 at 9:58:00 AM Cec
o use apply, e.g.:
user=> (defn foo [& stuff] stuff)
#'user/foo
user=> (defn bar [& things] (apply foo things))
#'user/bar
user=> (bar 1 2 3)
(1 2 3)
On Sat Feb 21 2015 at 9:58:00 AM Cecil Westerhof
wrote:
> I want to work with default values. For this I use:
>
I want to work with default values. For this I use:
[& nr]
This gives the value null to nr. So far so good.
But I want to propagate the value, because I want to fill the default at a
higher level.
I have:
(defn test-lucky-numbers-all
"Test all lucky number pe
Awesome! Thanks so much!
Anthony
On Sep 7, 2:10 am, Meikel Brandmeyer wrote:
> Hi,
>
> first of all we should start with the form we finally want to have:
>
> (defrecord Foo [a b c])
>
> (defn make-Foo
> [& {:keys [a b c] :or {a :x c :z}}]
> (Foo. a b c))
>
> ; Use as: (make-Foo :b :f) => (
Hi,
first of all we should start with the form we finally want to have:
(defrecord Foo [a b c])
(defn make-Foo
[& {:keys [a b c] :or {a :x c :z}}]
(Foo. a b c))
; Use as: (make-Foo :b :f) => (Foo. :x :f :z)
The only annoying part is the boilerplate of defining make-Foo.
What we would like
Disclamer: I'm a Clojure noob, so bad code follows...
I have been putzing around with implementing a Simple Temporal Network
(a graph structure for scheduling problems) in Clojure. In the
process, I wanted to generate records that had default values.
I ran into this blog post by cemerick
No, constructor functions are the correct way to accomplish this.
-S
On Aug 27, 5:16 pm, Darren Austin wrote:
> Hi folks,
>
> Is there a way to specify default values for the fields of a
> defrecord? Or barring that, is there a way to override or augment the
> constructor
Hi folks,
Is there a way to specify default values for the fields of a
defrecord? Or barring that, is there a way to override or augment the
constructor for the record?
That is, if I have:
(defrecord Foo [a b c d e f g])
I want to be able to create a new Foo with:
(Foo.)
and have default
On 12 Jul 2010, at 16:13, aria42 wrote:
> Is there a way to set up a map so that there is a default function
> which depending on the key returns a value if one is not present in
> the map. I can obviously write this with a deftype and have it
> implement Associative, Seqable, etc. so it behaves l
Is there a way to set up a map so that there is a default function
which depending on the key returns a value if one is not present in
the map. I can obviously write this with a deftype and have it
implement Associative, Seqable, etc. so it behaves like a built-in
map, but just wondering if there w
On Fri, Jan 22, 2010 at 5:41 PM, Raoul Duke wrote:
> hi,
>
> if i have (deftype map-db [next-id id-to-item-map]) i have to then do
> (map-db 0 {}) any time i want to make a new one. it would be nice to
> be able to add a function in my deftype so i could use (map-db) to get
> the same effect.
>
>
hi,
if i have (deftype map-db [next-id id-to-item-map]) i have to then do
(map-db 0 {}) any time i want to make a new one. it would be nice to
be able to add a function in my deftype so i could use (map-db) to get
the same effect.
?
--
You received this message because you are subscribed to the
Hi Mark,
Am 27.04.2009 um 23:42 schrieb Mark Volkmann:
Is there something in core or contrib that supports creating a map
where gets on undefined keys return a specified default value? For
example, I'd like to create a hashmap where the default value for
missing keys is zero.
You can specify
Is there something in core or contrib that supports creating a map
where gets on undefined keys return a specified default value? For
example, I'd like to create a hashmap where the default value for
missing keys is zero.
--
R. Mark Volkmann
Object Computing, Inc.
--~--~-~--~~--
15 matches
Mail list logo