Function Repository Resource:

FlipFunction

Source Notebook

Reverse the order of two arguments of a function

Contributed by: Nikolay Murzin

ResourceFunction["FlipFunction"][f]

gives a version of f in which its first two arguments are exchanged.

ResourceFunction["FlipFunction"][f,{i,j}]

exchanges arguments at positions i and j.

Details and Options

This function is closely related to the C combinator of the B, C, K, W combinatory logic system discovered by Haskell Curry in 1930.

Examples

Basic Examples (3) 

Make a flipped Power function:

In[1]:=
ResourceFunction["FlipFunction"][Power][x, y]
Out[1]=

Flip the order in which StringJoin joins its string arguments:

In[2]:=
ResourceFunction["FlipFunction"][StringJoin]["Hello", "World"]
Out[2]=

Flip the first and last arguments:

In[3]:=
ResourceFunction["FlipFunction"][f, {1, -1}][a, b, c, d, e]
Out[3]=

Properties and Relations (1) 

For two arguments, FlipFunction[f] is equivalent to Curry[f]:

In[4]:=
ResourceFunction["FlipFunction"][f][x, y]
Out[4]=
In[5]:=
Curry[f][x, y]
Out[5]=

Publisher

N. Murzin

Version History

  • 1.0.0 – 02 March 2020

Related Resources

License Information