[Cuis-dev] curried blocks

Mark Volkmann r.mark.volkmann at gmail.com
Fri Aug 2 16:53:52 PDT 2024


I wanted to see if it was possible to define a class that supports partial
application with blocks. The goal is to be able to pass fewer arguments
than a block requires and get back a new "block" that requires
the remaining arguments. Perhaps this has already been done and I just
didn't find it.

Here are examples of using my solution:

cb := CurriedBlock block: [:a :b | a + b].
cb valueWithArguments: #(2 3). "5"

cb2 := cb valueWithArguments: #(5). "a new CurriedBlock"
cb2 valueWithArguments: #(7). "12"

I attached my solution as a fileOut. I'd love to get some feedback in terms
of style and better ways to implement it. What would you do differently?

-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240802/946f7b68/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CurriedBlock.st
Type: application/octet-stream
Size: 1499 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240802/946f7b68/attachment.obj>


More information about the Cuis-dev mailing list