0% found this document useful (0 votes)
21 views

FunctionalExtras Documentation

Assorted convenience functions for Mathematica, especially useful for functional programming. Inspired by similar functions in Clojure.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

FunctionalExtras Documentation

Assorted convenience functions for Mathematica, especially useful for functional programming. Inspired by similar functions in Clojure.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

FunctionalExtras

Assorted convenience functions for Mathematica, inspired by similar


functions in Clojure

http://web.mit.edu/~gasc/www/software

Rationale

ÿ I often find that Mathematica is missing simple functions that I want. These are some of those.

Installation

ÿ Place the .m file somewhere in your Mathematica $Path. It is available at http://web.mit.edu/~-


gasc/www/software.

Use

ÿ Load the library:


In[1]:= Needs@"FunctionalExtras`"D

Included Functions

ì Inc[x]

Returns x plus one. Different from Increment because it does not modify x.

ì Dec[x]

Returns x minus one. Different from Decrement because it does not modify x.

ì Output[x]

Prints x and returns x. Different from Print because it returns x. Useful for debugging.

ì DoTo[x, f1, f2, f3, ...]

Same as x // f1 // f2 // f3 // ... or Composition[... , f3, f2, f1][x]. Nicer-looking than either.

ì EveryQ[list, pred]

Printed by Mathematica for Students


2 FunctionalExtras Documentation.nb

EveryQ[list, pred]

Returns True if pred is true of every element in list. Otherwise returns False.

ì NotEveryQ[list, pred]

Returns True if pred is not true of every element in list, i.e. it is false of any element. Otherwise
returns False.

ì AnyQ[list, pred]

Returns True if pred is true of any element in list. Otherwise returns False.

ì NotAnyQ[list, pred]

Returns True if pred is true of no element in list. Otherwise returns False.

ì Some[list, pred]

Returns the first element in list for which pred is true. Returns False if there is no such element.

ì FoldAll[f, list]

Folds (reduces) f over list, returning the result. Same as Fold[f, First[list], Rest[list]].

ì FoldAllList[f, list]

Folds (reduces) f over list, returning the list of all intermediate results. Same as FoldAll[f, First[list],
Rest[list]].

ì Negation[f]

Returns a function taking the same arguments as f but returning the opposite truth value.

License

ÿ FunctionalExtras is released under the MIT license.

Contributions

ÿ Are welcome.

Author
ì

Printed by Mathematica for Students


FunctionalExtras Documentation.nb 3

Author

ÿ Garth Sheldon-Coulson
http://web.mit.edu/~gasc/www
gasc ΑΤ mit ∆ΟΤ edu

Printed by Mathematica for Students

You might also like