MathGroup Archive 2009

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

Search the Archive

Function parameter passing?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99293] Function parameter passing?
  • From: nick.maj at mssm.edu
  • Date: Sat, 2 May 2009 05:57:37 -0400 (EDT)

Dear all,

this mathematica group has been of great help so far. I started a few
weeks ago and accomplished more than I ever have with LISP. Thank you
all again.

New Problem:

a = 3; b = 2; cutoff = a b; g = b;

data = {0, {10, 15}, 1, 20, 7, 55};

gen[a_, b___, c___] :=
  Flatten[Table[
    Partition[Union[Flatten[Range[i, cutoff + i, {a, b, c}]]], 2,
     1], {i, 0, cutoff - 1, cutoff}], 1];
width[gen_,
  width_] := {#1, #2 + (2 Mean[{#1, #2} - #1]*width/100)} & @@@ gen
hight[gen_, high_, low_] :=
  If[Mod[#[[1]], g] == 0, high, low] & /@ gen;
datacut[data_] := Flatten[Table[data, {cutoff/Length[data] + 1}], 1];
output[gen_, hight_, data_] :=
  Table[{data[[i]], gen[[i]], hight[[i]]}, {i, 1, Length[gen]}];

out1 = gen[a, b];
out2 = gen[a];

output[width[out1, - 0], hight[out1, 100, 50], datacut[data]]
output[width[out2, - 0], hight[out2, 100, 50], datacut[data]]

This all works so far. However, the "output" function is to cluttered
and repetitive.

output[ out1, -0, {100, 50}, data ] is what I'm after.

The slots are: [generator, width, hight, data]

But how. Thanks in advance, Nick.


  • Prev by Date: Re: Question about Tally on a list of lists
  • Next by Date: Re: MapAt problem with passing List
  • Previous by thread: Re: PROBLEM WITH HISTOGRAM3D
  • Next by thread: Re: Function parameter passing?