MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: [Newbie questions] function composition

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38094] RE: [mg38050] [Newbie questions] function composition
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 3 Dec 2002 04:30:19 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Francois,

If c = d = 1, then b = 1 also. So just add the definition...

f[f[a_, 1, 1], 1, e_] := f[f[a, b, 1/2], b, 1/2]

For your list problem, use Combinatorica.

Needs["DiscreteMath`Combinatorica`"]

?KSubsets
KSubsets[l, k] gives all subsets of set l containing exactly k elements, \
ordered lexicographically.

KSubsets[{a, b, c}, 2]
Thread[# -> {0, 0}] & /@ %

gives

{{a,b},{a,c},{b,c}}
{{a -> 0, b -> 0}, {a -> 0, c -> 0}, {b -> 0, c -> 0}}

The last statement works this way...

{a,b} -> {0,0}
Thread[%]

{a, b} -> {0, 0}
{a -> 0, b -> 0}

We then just map that function onto each of the three sets.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/





From: Francois Bernard Lauze [mailto:francois at itu.dk]
To: mathgroup at smc.vnet.net

Hi,

Hope I won't be too imprecise, I just started with mathematica
last Friday.
1)
I want to define a function, say f, with among others the following property
f[f[a,b,c],d,e] should be evaluated as f[f[a,b,1/2],b,1/2] in case
b = d and c = d = 1


2) from a list, say {a,b,c}, I would like to generate
{{b->0,c->0},{a->0,c->0},{a->0,b->0}
I guess I have understood the iterative way of doing that,
but what about a more functionqal form?

Thanks a lot,
Francois

--
Francois Lauze
The IT University of Copenhagen, Glentevej 67
2400 Kbh NV, Denmark
Tel (45) 38 16 89 29




  • Prev by Date: Re: [Newbie questions] function composition
  • Next by Date: Re: [Newbie questions] function composition
  • Previous by thread: Re: [Newbie questions] function composition
  • Next by thread: Re: [Newbie questions] function composition