For simplicity, this book will use a textual alternative to arrows. Instead of drawing an arrow, the templates contain self-applications of the function to the selector expression(s):
<#10244#>(d<#10244#><#10245#>efine<#10245#> <#10246#>(fun-for-los<#10246#> <#10247#>a-list-of-symbols)<#10247#> <#10248#>(c<#10248#><#10249#>ond<#10249#> <#10250#>[<#10250#><#10251#>(empty?<#10251#> <#10252#>a-list-of-symbols)<#10252#> <#10253#>...]<#10253#> <#10254#>[<#10254#><#10255#>e<#10255#><#10256#>lse<#10256#> <#10257#>...<#10257#> <#10258#>(first<#10258#> <#10259#>a-list-of-symbols)<#10259#> <#10260#>...<#10260#> <#10261#>...<#10261#> <#10262#>(fun-for-los<#10262#> <#10263#>(rest<#10263#> <#10264#>a-list-of-symbols))<#10264#> <#10265#>...]<#10265#><#10266#>))<#10266#>We refer to these self-applications as <#62212#><#10270#>NATURAL RECURSIONS<#10270#><#62212#>.
<#70966#>;; <#62216#><#10278#>how-many<#10278#> <#10279#>:<#10279#> <#10280#>list-of-symbols<#10280#> <#10281#><#10281#><#10282#>-;SPMgt;<#10282#><#10283#><#10283#> <#10284#>number<#10284#><#62216#><#70966#> <#70967#>;; to determine how many symbols are on <#62217#><#10285#>a-list-of-symbols<#10285#><#62217#><#70967#> <#10286#>(d<#10286#><#10287#>efine<#10287#> <#10288#>(how-many<#10288#> <#10289#>a-list-of-symbols)<#10289#> <#10290#>(c<#10290#><#10291#>ond<#10291#> <#10292#>[<#10292#><#10293#>(empty?<#10293#> <#10294#>a-list-of-symbols)<#10294#> <#10295#>...]<#10295#> <#10296#>[<#10296#><#10297#>e<#10297#><#10298#>lse<#10298#> <#10299#>...<#10299#> <#10300#>(first<#10300#> <#10301#>a-list-of-symbols)<#10301#> <#10302#>...<#10302#> <#10303#>...<#10303#> <#10304#>(how-many<#10304#> <#10305#>(rest<#10305#> <#10306#>a-list-of-symbols))<#10306#> <#10307#>...]<#10307#><#10308#>))<#10308#>The answer for the base case is <#62218#><#10311#>0<#10311#><#62218#> because the empty list contains nothing. The two expressions in the second clause compute the <#62219#><#10312#>first<#10312#><#62219#> item and the number of symbols on the <#62220#><#10313#>(rest<#10313#><#10314#> <#10314#><#10315#>a-list-of-symbols)<#10315#><#62220#>. To compute how many symbols there are on all of <#62221#><#10316#>a-list-of-symbols<#10316#><#62221#>, we just need to add <#62222#><#10317#>1<#10317#><#62222#> to the value of the latter expression:
<#10321#>(d<#10321#><#10322#>efine<#10322#> <#10323#>(how-many<#10323#> <#10324#>a-list-of-symbols)<#10324#> <#10325#>(c<#10325#><#10326#>ond<#10326#> <#10327#>[<#10327#><#10328#>(empty?<#10328#> <#10329#>a-list-of-symbols)<#10329#> <#10330#>0]<#10330#> <#10331#>[<#10331#><#10332#>else<#10332#> <#10333#>(+<#10333#> <#10334#>(how-many<#10334#> <#10335#>(rest<#10335#> <#10336#>a-list-of-symbols))<#10336#> <#10337#>1)]<#10337#><#10338#>))<#10338#>
<#10436#>Figure: The revised design recipe for recursive data<#10436#>
<#62230#>(Refines the recipes in figures~#figdesign1#10438>