Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

[J language] Calling a dyad as you would a monad
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)?


Report this thread to moderator Post Follow-up to this message
Old Post
Eighty
03-30-05 01:55 AM


Re: [J language] Calling a dyad as you would a monad
In 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

Report this thread to moderator Post Follow-up to this message
Old Post
Philip A. Viton
03-30-05 01:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

APL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:49 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.