MathGroup Archive 2009

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

Search the Archive

Re: Function parameter passing?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99513] Re: Function parameter passing?
  • From: nick.maj at mssm.edu
  • Date: Thu, 7 May 2009 06:33:17 -0400 (EDT)
  • References: <gth5dm$es2$1@smc.vnet.net>

Figured it out.

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_, highLow_] :=
  If[Mod[#[[1]], g] == 0, highLow[[1]], highLow[[2]]] & /@ 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]}];
final[gen_, w_: 0, highLow_: {100, 50}, data_] :=
  output[width[gen, w], hight[gen, highLow], datacut[data]];

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

final[out1, data]
final[out2, -50, {40, 30}, data]

And it does defaults too. However, can I avoid the extra step from the
output to the final function?

Thanks in advance, Nick.


  • Prev by Date: Re: Picking Off Lists That Have No Numbers
  • Next by Date: Re: Bug with Hypergeometric2F1?
  • Previous by thread: Function parameter passing?
  • Next by thread: Re: MapAt problem with passing List