Vocabulary/mcapdot

From J Wiki
Jump to navigation Jump to search

>> <<   Back to: Vocabulary Thru to: Dictionary

[x] u M. y Memo Adverb

Rank -- depends on the rank of u -- WHY IS THIS IMPORTANT?


u M. is identical in function to verb u, except that it might be faster if u is highly recursive.

The verb created by  u M. may keep a record of arguments and results, and returns the previously-calculated result if called with previously-seen arguments.

This technique is called memoization.

The verb u must not have side effects, i.e. its actual execution must not do anything significant, as distinct from the result it returns.

This is because you can no longer rely on it actually being executed.


Details

1. u M. records only atomic arguments.

2. The size of the table used to record arguments and results is not under user control.


Oddities

1. If an argument to  u M. is an atom, it must be numeric.