<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Cuis includes an implementation already.</p>
<p>Have a look at BlockClosure>>withFirstArg:</p>
<p><a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/Partial_application">https://en.wikipedia.org/wiki/Partial_application</a><br>
<br>
[ :a :b | a + b ] value: 1 value: 2<br>
[ :a :b | a + b ] withFirstArg: 1<br>
([ :a :b | a + b ] withFirstArg: 1) value: 2<br>
([ :a :b | a + b ] withFirstArg: 1) withFirstArg: 2<br>
(([ :a :b | a + b ] withFirstArg: 1) withFirstArg: 2) value<br>
<br>
([ :a :b | a - b ] withFirstArg: 1) value: 2.</p>
<p><br>
</p>
<p>Yours supports more arguments, though; you could try adding a
#withPartialArgs: to BlockClosure if #withFirstArg: is not enough
in your opinion.</p>
<p><br>
</p>
<p> Mariano</p>
<p><br>
</p>
<div class="moz-cite-prefix">El 2/8/24 a las 20:53, Mark Volkmann
via Cuis-dev escribió:<br>
</div>
<blockquote type="cite"
cite="mid:CAFfRWnVX8cUU8kZjX2kBfigG6c-nNSNGhUfw-FrE_ReqEzTr2w@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">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.
<div><br>
</div>
<div>Here are examples of using my solution:</div>
<div><br>
</div>
<div><font face="monospace">cb := CurriedBlock block: [:a :b | a
+ b].<br>
cb valueWithArguments: #(2 3). "5"</font></div>
<div><font face="monospace"><br>
cb2 := cb valueWithArguments: #(5). "a new CurriedBlock"<br>
cb2 valueWithArguments: #(7). "12"</font><br>
</div>
<div><br>
</div>
<div>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?
<div>
<div><br>
</div>
<span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div><font face="arial, helvetica, sans-serif">R.
Mark Volkmann</font></div>
<div><span
style="font-size:12.8000001907349px"><font
face="arial, helvetica, sans-serif">Object
Computing, Inc.</font></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
</blockquote>
</body>
</html>