[kepler-dev] Re: type signatures in the expression language

Tobin Fricke tobin at splorg.org
Wed Aug 4 22:08:20 PDT 2004


On Sat, 31 Jul 2004, Edward A Lee wrote:

> >Specific application: say I have an array x={double} and y={double} and I
> >want to produce {{x=double,y=double,z=double}} for all pairs of values
> >(x,y) and with z = f(x,y) for a function f.  Can/should this be described
> >in the expression language or should I just write the java actor?
>
> Ideally, this would be easily done in the expression language.
> However, I don't think we have the suite of primitives there yet...

reverse_map = function(F:{(function(x:general)general)},x:general)
  map(function(f:(function(x:general)general)) f(x), F)

make_grid = function(xs:{double}, ys:{double})
  map((function(y:double) (reverse_map(map((function (x:double) (function
(y:double) {x=x, y=y})), xs), y))), ys)

>> xs = [0:1:1].toArray
{0, 1}
>> make_grid(xs, xs)
{{{x = 0, y = 0}, {x = 1, y = 0}}, {{x = 0, y = 1}, {x = 1, y = 1}}}

success! er... almost!

need concatenate({{general}}) --> {general}

Tobin






More information about the Kepler-dev mailing list