Kap: Difference between revisions

Jump to navigation Jump to search
No edit summary
(inline code to improve sentence flow)
Line 21: Line 21:
== Lazy evaluation ==
== Lazy evaluation ==


The main difference compared to APL is that KAP is lazy-evaluated. This means that the language gives the developers very loose guarantees when (or if, and how many times) a function will actually be invoked. For example, the following code will only make a single call to the function:
The main difference compared to APL is that KAP is lazy-evaluated. This means that the language gives the developers very loose guarantees when (or if, and how many times) a function will actually be invoked. For example, <source lang=apl inline>↑ f¨ ⍳10</source> will only make a single call to <source lang=apl inline>f</source> because <code>f¨ ⍳10</code> will not immediately evaluate the result but only return a delayed evaluation. Since all but the first result is then discarded, those results will never be computed.
 
<source lang=apl>
↑ f¨ ⍳10
</source>
 
This is because the call to <code>f¨ ⍳10</code> will not immediately evaluate the result but only return a delayed evaluation. Since all but the first result is then discarded, those results will never be computed.


== Differences from APL ==
== Differences from APL ==
Retrieved from ‘https://aplwiki.com/wiki/Kap