<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mojopuzzler.org/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Currying</id>
	<title>Currying - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mojopuzzler.org/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Currying"/>
	<link rel="alternate" type="text/html" href="https://mojopuzzler.org/mediawiki/index.php?title=Currying&amp;action=history"/>
	<updated>2026-05-05T23:56:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://mojopuzzler.org/mediawiki/index.php?title=Currying&amp;diff=2241&amp;oldid=prev</id>
		<title>Gneale: Created page with &quot;===== Return to: Chialisp ===== &lt;h2&gt;Example 1&lt;/h2&gt; *&lt;code&gt;cdv clsp curry -i include io_puz.clvm -a 0x7cac37d6245033e764e02b27b4898645df9dbd5ea5d2d8ef030cfa600ca33090 -a 0x2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 -a ff01ffff33ffa0656214f18f80a85a30f97cafa0fdfd29578d5e8030316b21e36552f9172c49d1ff018080 -x&lt;/code&gt; &lt;h2&gt;Example 2&lt;/h2&gt; *&lt;code&gt;cdv clsp curry -i include io_puz.clvm -a 0x7cac37d6245033e764e02b27b4898645df9dbd5ea5d2d8ef030cfa600...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mojopuzzler.org/mediawiki/index.php?title=Currying&amp;diff=2241&amp;oldid=prev"/>
		<updated>2023-11-17T15:38:03Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;===== Return to: &lt;a href=&quot;/mediawiki/index.php/Chialisp&quot; title=&quot;Chialisp&quot;&gt;Chialisp&lt;/a&gt; ===== &amp;lt;h2&amp;gt;Example 1&amp;lt;/h2&amp;gt; *&amp;lt;code&amp;gt;cdv clsp curry -i include io_puz.clvm -a 0x7cac37d6245033e764e02b27b4898645df9dbd5ea5d2d8ef030cfa600ca33090 -a 0x2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 -a ff01ffff33ffa0656214f18f80a85a30f97cafa0fdfd29578d5e8030316b21e36552f9172c49d1ff018080 -x&amp;lt;/code&amp;gt; &amp;lt;h2&amp;gt;Example 2&amp;lt;/h2&amp;gt; *&amp;lt;code&amp;gt;cdv clsp curry -i include io_puz.clvm -a 0x7cac37d6245033e764e02b27b4898645df9dbd5ea5d2d8ef030cfa600...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;===== Return to: [[Chialisp|Chialisp]] =====&lt;br /&gt;
&amp;lt;h2&amp;gt;Example 1&amp;lt;/h2&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;cdv clsp curry -i include io_puz.clvm -a 0x7cac37d6245033e764e02b27b4898645df9dbd5ea5d2d8ef030cfa600ca33090 -a 0x2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 -a ff01ffff33ffa0656214f18f80a85a30f97cafa0fdfd29578d5e8030316b21e36552f9172c49d1ff018080 -x&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Example 2&amp;lt;/h2&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;cdv clsp curry -i include io_puz.clvm -a 0x7cac37d6245033e764e02b27b4898645df9dbd5ea5d2d8ef030cfa600ca33090 -a 0x2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 -a ff01ffff33ffa0656214f18f80a85a30f97cafa0fdfd29578d5e8030316b21e36552f9172c49d1ff018080 --treehash&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Example 3&amp;lt;/h2&amp;gt;&lt;br /&gt;
Take for instance the password protected coin tutorial example which has a puzzle that looks like this &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (mod (password new_puzhash amount)&lt;br /&gt;
    (defconstant CREATE_COIN 51)&lt;br /&gt;
&lt;br /&gt;
    (if (= (sha256 password) (q . 0x2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824))&lt;br /&gt;
        (list (list CREATE_COIN new_puzhash amount))&lt;br /&gt;
        (x)&lt;br /&gt;
    )&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
which yields clvm that looks like this (puzzle_hash)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;(a (q 2 (i (= (sha256 5) (q . 0x2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824)) (q 4 (c 2 (c 11 (c 23 ()))) ()) (q 8)) 1) (c (q . 51) 1))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and a solution that looks like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;(q . (hello 0xe57f6cc4a9f35ee60b95889a8c8f2e5e7a273a9fcf716276ee1f4c6f932b7ea6 1))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can accomplish the same thing by currying...&lt;br /&gt;
Curried version: &lt;br /&gt;
&lt;br /&gt;
 (mod (HASHED_PASSWORD password new_puzhash amount)&lt;br /&gt;
    (defconstant CREATE_COIN 51)&lt;br /&gt;
&lt;br /&gt;
    (if (= (sha256 password) HASHED_PASSWORD)&lt;br /&gt;
        (list (list CREATE_COIN new_puzhash amount))&lt;br /&gt;
        (x)&lt;br /&gt;
    )&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
The convention is to ALL_CAPS values that will be curried in. We can actually curry in the same hashed password from our tutorial example by doing &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cdv clsp curry -a 0x2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 curry_ppc.clvm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which yields puzzle_hash&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;(a (q 2 (q 2 (i (= (sha256 11) 5) (q 4 (c 2 (c 23 (c 47 ()))) ()) (q 8)) 1) (c (q . 51) 1)) (c (q . 0x2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824) 1))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting clvm code is slightly different from non-curried versus curried, yet they both spend to the same solution so it seems currying is just technique preference.&lt;br /&gt;
&lt;br /&gt;
My understanding is that currying in values like this makes the base Chialisp code more modular and reusable. In the case of password protected coin tutorial you could expect a changed password frequently.&lt;/div&gt;</summary>
		<author><name>Gneale</name></author>
	</entry>
</feed>