Code Comments
Programming Forum and web based access to our favorite programming groups.I want to define a function/verb f(x) that says if x is one of the chars a, b or c. Suppose x is the argument. Then I want: f =: x e. 'abc' But I can't name the argument explicitly (can I?), so I don't know how to do this. The problem is that when I call f, the argument goes on the right side, but I need to put it on the left side. Is there a flip function so that the left and right arguments of a dyad are switched (so x dyad y == y (flip dyad) x)? Is there a bind function so that I can bind the right argument (so x dyad y == bind dyad y x)?
Post Follow-up to this messageIn article <1111676518.020328.249890@g14g2000cwa.googlegroups.com>, eightyx@gmail.com says... > I want to define a function/verb f(x) that says if x is one of the > chars a, b or c. > > Suppose x is the argument. Then I want: > > f =: x e. 'abc' > > But I can't name the argument explicitly (can I?), so I don't know how > to do this. The problem is that when I call f, the argument goes on the > right side, but I need to put it on the left side. > > Is there a flip function so that the left and right arguments of a dyad > are switched (so x dyad y == y (flip dyad) x)? > > Is there a bind function so that I can bind the right argument (so x > dyad y == bind dyad y x)? > > The right argument in an explicit verb definition can be referred to as y. (and the left is x.) So the following may do what you want (sorta klunky def) f =: 3 : 0 +./ y. e. 'abc' ) Note that we take the "or" of the results of e. then f 'abc' is 1 while f 'def' is 0 flip function: look at dyad ~ If 1 % 2 is 0.5 1 %~ 2 is 2 No sure I understand the "bind" question , but look at & -- Phil Viton Ohio State University
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.