[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: composing projections
> I'd like to compose projections.
> For example, given a list of tuples of lists I want to map a function that
> finds the length of the first lists in each tuple:
> map ((length o proj1) my_tuple)
> But this generates the error: "Projection expressions may only appear as
> operators of an application."
> Can anyone suggest a way to accomplish this?
> Ben Kleinman
A hack solution is to define your own projection function in terms of
I tried writing the spec as you described, got your error, replaced
PROJ_1 with my own projection function, and got it to work. I've
appended my spec below.
I'm sure there's a better solution though.
mapping_tuples_of_lists % [ parameters ]
% assuming declarations
int_list : TYPE = list[int]
tuple_list : TYPE = [int_list, int_list]
my_proj(t_l : tuple_list) : int_list = PROJ_1(t_l)
foo_t : TYPE = list[tuple_list]
b : foo_t
b_length : int = length(map[tuple_list, int_list](my_proj,b))
Dr. John Hoffman ||
Secure Computing Corporation || What do you want to
2675 Long Lake Road || read for, when you
Roseville, MN 55124 || can watch TV?
Fax :(612)628-2701 || - Matilda's Father