turtlestitch/libraries/word-sentence.xml

1 wiersz
35 KiB
XML
Czysty Zwykły widok Historia

<blocks app="Snap! 6, https://snap.berkeley.edu" version="1"><block-definition s="all but first letter of %&apos;string&apos;" type="reporter" category="operators"><comment w="199" collapsed="false">Takes a text string as input, and reports a new text string containing all but the first character of the input.</comment><header></header><code></code><translations>pt:_ sem o primeiro caractere&#xD;</translations><inputs><input type="%txt"></input></inputs><script><block s="doDeclareVariables"><list><l>result</l><l>i</l></list></block><block s="doIf"><block s="reportIsA"><block var="string"/><l><option>list</option></l></block><script><block s="doReport"><block s="reportMap"><block s="reifyReporter"><autolambda><custom-block s="all but first letter of %txt"><l></l></custom-block></autolambda><list></list></block><block var="string"/></block></block></script></block><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>str</l></list><l>return str.slice(1);</l></block><list><custom-block s="require nonempty %s %s"><block var="string"/><l>All but first of empty word.</l></custom-block></list></block></block></script><scripts><script x="11.333333333333334" y="249.0000000000001"><block s="doWarp"><script><block s="doSetVar"><l>result</l><l></l></block><block s="doSetVar"><l>i</l><l>2</l></block><block s="doUntil"><block s="reportGreaterThan"><block var="i"/><block s="reportStringSize"><block var="string"/></block></block><script><block s="doSetVar"><l>result</l><block s="reportJoinWords"><list><block var="result"/><block s="reportLetter"><block var="i"/><block var="string"/></block></list></block></block><block s="doChangeVar"><l>i</l><l>1</l></block></script></block><block s="doReport"><block var="result"/></block></script></block></script></scripts></block-definition><block-definition s="all but first word of %&apos;sentence&apos;" type="reporter" category="operators"><comment w="223.000001" collapsed="false">Takes a text string as input, divides it into words treating one or more spaces as a word separator (only spaces count; punctuation is part of the word) and reports a text string containing all but the first word, with one space between words and no spaces at the beginning or end. (Note: consider using SENTENCE➞LIST and processing the resulting list instead of doing recursion on sentences in text string form. List operations are faster.)</comment><header></header><code></code><translations>pt:_ sem a primeira palavra&#xD;</translations><inputs><input type="%txt"></input></inputs><script><block s="doIf"><block s="reportIsA"><block var="sentence"/><l><option>list</option></l></block><script><block s="doIfElse"><block s="reportListIsEmpty"><block var="sentence"/></block><script><custom-block s="error %txt"><l>All but first of empty sentence.</l></custom-block></script><script><block s="doReport"><block s="reportCDR"><block var="sentence"/></block></block></script></block></script></block><block s="doReport"><custom-block s="list $arrowRight sentence %l"><block s="reportCDR"><custom-block s="require nonempty %s %s"><custom-block s="sentence $arrowRight list %txt"><block var="sentence"/></custom-block><l>All but first of empty sentence.</l></custom-block></block></custom-block></block></script><scripts><script x="13.333333333333334" y="368.8888888888889"><block s="doDeclareVariables"><list><l>index</l><l>bf</l></list></block><block s="doWarp"><script><block s="doSetVar"><l>bf</l><l></l></block><block s="doSetVar"><l>index</l><l>1</l></block><block s="doUntil"><block s="reportOr"><block s="reportEquals"><block var="index"/><block s="reportStringSize"><block var="sentence"/></block></block><block s="reportNot"><block s="reportEquals"><block s="reportLetter"><block var="index"/><block var="sentence"/></block><l> </l></block></block></block><script><block s="doChangeVar"><l>index</l><l>1</l></block></script></block><block s="doIf"><block s="reportEquals"><block s="reportLetter"><block var="index"/><block var="sentence"/></block><l> </l></block><script><custom-block s="error %txt"><l>All but first of empt