curry, rcurry - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Operations : Operators : curry

curry, rcurry

Generate a curried procedure

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

curry(p)

curry(p, rest)

rcurry(p)

rcurry(p, rest)

Parameters

p

-

procedure or name to be curried

rest

-

(optional) expression sequence of arguments to be curried over

Description

• 

The procedure curry returns a procedure derived from its first argument p by currying on the remaining arguments, if any, in procedure application.

• 

Given a Maple expression f (usually a procedure or a name), the curried procedure curry( f, x1, x2, ..., xn ) is the procedure g for which gt1,t2,...,tm=fx1,x2,...,xn,t1,t2,...,tm. In the case in which n=0, currying on no arguments returns a procedure that calls f.

• 

It is useful for producing a derived procedure from an existing one within the context of other commands such as map, zip, select, remove, and apply.

• 

The procedure rcurry is similar to curry, but curries on the specified arguments from the right of the parameter list.

• 

The definition of currying used here is adapted from "The Haskell 98 Report" ("The Haskell Language Report"), by Simon Peyton Jones, et. al. (http://haskell.org/onlinereport/)

Examples

gcurryf:

gx,y,z

fx,y,z

(1)

gcurryf,1:

gy,z

f1,y,z

(2)

gcurryf,1,2:

gz

f1,2,z

(3)

grcurryf:

gx,y,z

fx,y,z

(4)

grcurryf,1:

gy,z

fy,z,1

(5)

grcurryf,1,2:

gz

fz,1,2

(6)

mapcurry`+`,1,1,2,3,4

2,3,4,5

(7)

mapcurry`*`,2,1,2,3,4

2,4,6,8

(8)

L2a,6b,24c:

mapcurryapplyop,ifactor,1,L

2a,23b,233c

(9)

maprcurryop,a,b,c,1,2,3

a,b,c

(10)

Suppose you want to print a table, specified as a list of equations, in a neat form.

morse-=-....-,.=.-.-.-,'=.----.,(=-.--.-,)=-.--.-,,=--..--,/=-..-.,0=-----,1=.----,2=..---,3=...--,4=....-,5=.....,6=-....,7=--...,8=---..,9=----.,:=---...,==-...-,?=..--..,a=.-,b=-...,c=-.-.,d=-..,e=.,f=..-.,g=--.,h=....,i=..,j=.---,k=-.-,l=.-..,m=--,n=-.,o=---,p=.--.,q=--.-,r=.-.,s=...,t=-,u=..-,v=...-,w=.--,x=-..-,y=-.--,z=--..:

tsortmorse,u,v→lexorderlhsu,lhsv:

format<tr><td>%s</td><td>%s</td></tr> &colon;

format%s %s &colon;

zipcurryprintf&comma;format&comma;maplhs&comma;t&comma;maprhs&comma;t&colon;

'    .----.
(    -.--.-
)    -.--.-
,    --..--
-    -....-
.    .-.-.-
/    -..-.
0    -----
1    .----
2    ..---
3    ...--
4    ....-
5    .....
6    -....
7    --...
8    ---..
9    ----.
:    ---...
=    -...-
?    ..--..
a    .-
b    -...
c    -.-.
d    -..
e    .
f    ..-.
g    --.
h    ....
i    ..
j    .---
k    -.-
l    .-..
m    --
n    -.
o    ---
p    .--.
q    --.-
r    .-.
s    ...
t    -
u    ..-
v    ...-
w    .--
x    -..-
y    -.--
z    --..

See Also

apply

eval

function

lexorder

map

sort

type[function]

zip

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam