How can I create a list of functions?

Suppose I have a function as followsmyadd:{y + z + 2*x}I can create the following functionfunc: myadd[;7;11]which is the equivalent tofunc:{7 + 11 + 2*x}Suppose now I have a list of coordinates as followslist: 1+ til 2coords: raze list,/::listcoords equals ((1;1);(1;2);(2;1);(2;2))If I want these to represent my y and z values, how would I map to alist of functions equivalent tomapped: ({1 + 1 + 2*x};{1 + 2 + 2*x};{2 + 1 + 2*x};{2 + 2 + 2*x})And then once I have mapped these functions what would be the syntaxto combine my functions with the following list representing x values?mynums: 4 6 9 10I have been playing around with each but cannot get the syntax right

If you don’t mind some anonymous functions you could:

fs:{myadd[;x;y]}./:coords

check:

(fs@'mynums)=myadd ./:mynums,'coords

Br,

Bartosz

mapped @’ mynums

you can use .’ for multivalent functions

Thank you for the replies. I tried to make a small modification and
unfortunately got stuck again. Suppose I make the following change
myadd:{y + z + 2*x}greater:{$[20>myadd[x;y;z];:x+1;x]}list: 1+ til
2coords: raze list,/::listfs:{greater[;x;y]}./:coords
The idea is to cycle through successive values of x until myadd is
greater than or equal to 20. I’m trying to find the values of x that
produce this result. fs contains the correct functions i.e.
fs[0]/[0] produces 9fs[1]/[0] produces 9fs[2]/[0] produces 9fs[3]/[0] produ=
ces 8
How would I get 9 9 9 8 into a list? I’m trying to do something like
(/[0]) each fs but once again the syntax is eluding me
On Wed, Nov 23, 2011 at 12:16 AM, Peter Byrne <peter.byrne> wrote=
:
> mapped @’ mynums
>
> you can use .’ for multivalent functions
>
> On Nov 22, 11:13=C2=A0am, Bartosz Kaliszuk <bartosz.kalis…>
> wrote:
>> If you don’t mind some anonymous functions you could:
>>
>> fs:{myadd[;x;y]}./:coords
>>
>> check:
>> (fs@'mynums)=3Dmyadd ./:mynums,'coords
>>
>> Br,
>> Bartosz
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Nov 22, 2011 at 10:46 AM, Don Nguyen <d…> wrote:
>> > Suppose I have a function as follows
>>
>> > myadd:{y + z + 2x}
>>
>> > I can create the following function
>>
>> > func: myadd[;7;11]
>>
>> > which is the equivalent to
>>
>> > func:{7 + 11 + 2
x}
>>
>> > Suppose now I have a list of coordinates as follows
>>
>> > list: 1+ til 2
>> > coords: raze list,/::list
>>
>> > coords equals ((1;1);(1;2);(2;1);(2;2))
>>
>> > If I want these to represent my y and z values, how would I map to a
>> > list of functions equivalent to
>>
>> > mapped: ({1 + 1 + 2x};{1 + 2 + 2x};{2 + 1 + 2x};{2 + 2 + 2x})
>>
>> > And then once I have mapped these functions what would be the syntax
>> > to combine my functions with the following list representing x values?
>>
>> > mynums: 4 6 9 10
>>
>> > I have been playing around with each but cannot get the syntax right
>>
>> > –
>> > You received this message because you are subscribed to the Google Gro=
ups
>> > “Kdb+ Personal Developers” group.
>> > To post to this group, send email to personal-kdbplus@googlegroups.com=
.
>> > To unsubscribe from this group, send email to
>> > personal-kdbplus+unsubscribe@googlegroups.com.
>> > For more options, visit this group at
>> >http://groups.google.com/group/personal-kdbplus?hl=3Den.
>>
>> –
>> Regards
>> Bartosz Kaliszuk
>> bartosz(dot)kaliszuk(at)gmail(dot)com
>
> –
>

Submitted via Google Groups</d…></bartosz.kalis…></peter.byrne>

repost to correct whitespace

Thank you for the replies. I tried to make a small modification and unfortunately got stuck again. Suppose I make the following change

myadd:{y + z + 2*x}

greater:{$[20>myadd[x;y;z];:x+1;x]}

list: 1+ til 2

coords: raze list,/::list

fs:{greater[;x;y]}./:coords

The idea is to cycle through successive values of x until myadd is greater than or equal to 20. I’m trying to find the values of x that produce this result. fs contains the correct functions i.e.

fs[0]/[0] produces 9

fs[1]/[0] produces 9

fs[2]/[0] produces 9

fs[3]/[0] produces 8

How would I get 9 9 9 8 into a list? I’m trying to do something like

(/[0]) each fs but once again the syntax is eluding me

q)myadd:{y + z + 2*x}

q)list: 1+ til 2

q)coords: raze list,/::list

q)greater:{$[20>myadd[x;y;z];:x+1;x]}

q)mynums: 4 6 9 10

q)

q)

q)

q)f:{.[myadd]'[y,'x]}

q)f[coords] mynums

10 15 21 24

q)f[coords] 0

2 3 3 4

q)

q)g:{.[greater]'[y,'x]}

q)g[coords]/[0]

9 9 9 8

Regards,

Junan

Thank you works perfectly