Semantics of apply

62 views
Skip to first unread message

Praki

unread,
Jun 8, 2011, 11:54:55 PM6/8/11
to Cat Language
Hi,

I am Cat-noob and trying out some examples in the Javascript
implementation. apply is documented as "Applies a function on the
stack to the rest of the stack.". However, "2 4 6 [dup *] apply"
produces" 2 4 36". It is clearly not applying "dup *" to the "rest of
the stack".

So, what exactly is apply expected to?

Thanks,

Christopher Diggins

unread,
Jun 13, 2011, 3:31:32 PM6/13/11
to catla...@googlegroups.com
Sorry about the confusion. It should be rephrased as "Apply applies a
function to the stack, after it is first removed". This is to
distinguish itself from combinators (e.g. "m") that are left on the
stack when applied, which is admittedly the exception not the rule.

Hope this helps.

Christopher

> --
> You received this message because you are subscribed to the Google Groups "Cat Language" group.
> To post to this group, send email to catla...@googlegroups.com.
> To unsubscribe from this group, send email to catlanguage...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/catlanguage?hl=en.
>
>

Grahack

unread,
Apr 25, 2012, 7:51:50 AM4/25/12
to catla...@googlegroups.com
'dup *' is applied to the rest of the stack, but only consumes one value and produces one (the square of the value consumed). Not to be confused with 'map'.
Reply all
Reply to author
Forward
0 new messages