kopia lustrzana https://github.com/backface/turtlestitch
1 wiersz
21 KiB
XML
1 wiersz
21 KiB
XML
<blocks app="Snap! 7, https://snap.berkeley.edu" version="2"><block-definition s="all but first letter of %'string'" 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
ca:_ sense la primera lletra
</translations><inputs><input type="%txt"></input></inputs><script><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="reportJoinWords"><block s="reportCDR"><block s="reportTextSplit"><custom-block s="require nonempty %s %s"><block var="string"/><l>All but first of empty word.</l></custom-block><l><option>letter</option></l></block></block></block></block></script></block-definition><block-definition s="all but first word of %'sentence'" 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
ca:_ sense la primera paraula
</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></block-definition><block-definition s="all but last letter of %'string'" type="reporter" category="operators"><comment w="218" collapsed="false">Takes a text string as input, and reports a new text string containing all but the last letter of the input.</comment><header></header><code></code><translations>pt:_ sem o último caractere
ca:_ sense la darrera lletra
</translations><inputs><input type="%txt"></input></inputs><script><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 last letter of %txt"><l></l></custom-block></autolambda><list></list></block><block var="string"/></block></block></script></block><block s="doReport"><block s="reportJoinWords"><block s="reportListAttribute"><l><option>reverse</option></l><block s="reportCDR"><block s="reportListAttribute"><l><option>reverse</option></l><block s="reportTextSplit"><custom-block s="require nonempty %s %s"><block var="string"/><l>All but first of empty word.</l></custom-block><l><option>letter</option></l></block></block></block></block></block></block></script></block-definition><block-definition s="all but last word of %'sentence'" type="reporter" category="operators"><comment w="211.99999999999997" 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 last 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 última palavra
ca:_ sense la darrera paraula
</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 last of empty sentence.</l></custom-block></script><script><block s="doReport"><block s="reportListAttribute"><l><option>reverse</option></l><block s="reportCDR"><block s="reportListAttribute"><l><option>reverse</option></l><block var="sentence"/></block></block></block></block></script></block></script></block><block s="doReport"><custom-block s="list $arrowRight sentence %l"><block s="reportListAttribute"><l><option>reverse</option></l><block s="reportCDR"><block s="reportListAttribute"><l><option>reverse</option></l><custom-block s="require nonempty %s %s"><custom-block s="sentence $arrowRight list %txt"><block var="sentence"/></custom-block><l>All but last of empty sentence.</l></custom-block></block></block></block></custom-block></block></script></block-definition><block-definition s="first word of %'sentence'" type="reporter" category="operators"><comment w="236" 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 only the first word, with no spaces before or after it.</comment><header></header><code></code><translations>pt:a primeira palavra de _
ca:primera paraula de _
</translations><inputs><input type="%txt"></input></inputs><script><block s="doIfElse"><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>First of empty sentence.</l></custom-block></script><script><block s="doReport"><block s="reportListItem"><l>1</l><block var="sentence"/></block></block></script></block></script><script><block s="doReport"><block s="reportListItem"><l>1</l><custom-block s="require nonempty %s %s"><custom-block s="sentence $arrowRight list %txt"><block var="sentence"/></custom-block><l>First of empty sentence.</l></custom-block></block></block></script></block></script></block-definition><block-definition s="last letter of %'word'" type="reporter" category="operators"><comment w="260" collapsed="false">Takes a text string as input, and reports the last character in the string.</comment><header></header><code></code><translations>pt:o último caractere de _
ca:primera lletra de _
</translations><inputs><input type="%txt"></input></inputs><script><block s="doIf"><block s="reportIsA"><block var="word"/><l><option>list</option></l></block><script><block s="doReport"><block s="reportMap"><block s="reifyReporter"><autolambda><custom-block s="last letter of %txt"><l></l></custom-block></autolambda><list></list></block><block var="word"/></block></block></script></block><block s="doIf"><block s="reportEquals"><block s="reportStringSize"><block var="word"/></block><l>0</l></block><script><custom-block s="error %txt"><l>Last of empty word.</l></custom-block></script></block><block s="doReport"><block s="reportLetter"><block s="reportStringSize"><block var="word"/></block><block var="word"/></block></block></script></block-definition><block-definition s="last word of %'sentence'" type="reporter" category="operators"><comment w="262" 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 only the last word of the input, with no spaces before or after it.</comment><header></header><code></code><translations>pt:a última palavra de _
ca:darrera paraula de _
</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>Last of empty sentence.</l></custom-block></script><script><block s="doReport"><block s="reportListItem"><l><option>last</option></l><block var="sentence"/></block></block></script></block></script></block><block s="doReport"><block s="reportListItem"><l><option>last</option></l><custom-block s="require nonempty %s %s"><custom-block s="sentence $arrowRight list %txt"><block var="sentence"/></custom-block><l>Last of empty sentence.</l></custom-block></block></block></script></block-definition><block-definition s="empty word? %'word'" type="predicate" category="operators"><comment w="208" collapsed="false">Takes a text string as input, and reports TRUE if the string has no characters in it of any kind, otherwise false.</comment><header></header><code></code><translations>pt:a palavra _ está vazia
ca:paraula buida? _
</translations><inputs><input type="%txt"></input></inputs><script><block s="doIf"><block s="reportIsA"><block var="word"/><l><option>list</option></l></block><script><block s="doReport"><block s="reportMap"><block s="reifyReporter"><autolambda><custom-block s="empty word? %txt"><l></l></custom-block></autolambda><list></list></block><block var="word"/></block></block></script></block><block s="doReport"><block s="reportEquals"><block s="reportStringSize"><block var="word"/></block><l>0</l></block></block></script></block-definition><block-definition s="empty sentence? %'sentence'" type="predicate" category="operators"><comment w="221" collapsed="false">Takes a text string as input, and reports TRUE if the input contains no characters other than spaces (therefore, no words when the string is considered as a sentence), otherwise FALSE.</comment><header></header><code></code><translations>pt:a frase _ está vazia
ca:frase buida? _
</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="doReport"><block s="reportListIsEmpty"><block var="sentence"/></block></block></script></block><block s="doReport"><block s="reportListIsEmpty"><custom-block s="sentence $arrowRight list %txt"><block var="sentence"/></custom-block></block></block></script></block-definition><block-definition s="join words %'words'" type="reporter" category="operators"><comment x="0" y="0" w="230.66666666666666" collapsed="false">Like JOIN, takes any number of words (text strings) and reports a sentence with its inputs concatenated, but inserts a blank space between the inputs.
Consider using SENTENCE (Lists palette) instead.</comment><header></header><code></code><translations>de:füge Wörter zusammen _
ca:uneix les paraules _
es:unir las palabras _
fr:fusionne les mots _
pt:uma frase com as palavras _
</translations><inputs><input type="%mult%txt"></input></inputs><script><block s="doIf"><block s="reportListIsEmpty"><block var="words"/></block><script><block s="doReport"><l></l></block></script></block><block s="doDeclareVariables"><list><l>first</l><l>bf</l></list></block><block s="doSetVar"><l>first</l><block s="reportIfElse"><block s="reportIsA"><block s="reportListItem"><l>1</l><block var="words"/></block><l><option>list</option></l></block><custom-block s="join words %mult%txt"><block s="reportListItem"><l>1</l><block var="words"/></block></custom-block><block s="reportListItem"><l>1</l><block var="words"/></block></block></block><block s="doSetVar"><l>bf</l><custom-block s="join words %mult%txt"><block s="reportCDR"><block var="words"/></block></custom-block></block><block s="doIf"><custom-block s="empty sentence? %txt"><block var="bf"/></custom-block><script><block s="doReport"><block var="first"/></block></script></block><block s="doIf"><custom-block s="empty sentence? %txt"><block var="first"/></custom-block><script><block s="doReport"><block var="bf"/></block></script></block><block s="doReport"><block s="reportJoinWords"><list><block var="first"/><l> </l><block var="bf"/></list></block></block></script></block-definition><block-definition s="list $arrowRight sentence %'data'" type="reporter" category="operators"><comment x="0" y="0" w="165.33333333333334" collapsed="false">Takes a sentence in list form and reports the sentence as a text string.</comment><header></header><code></code><translations>de:Liste $arrowRight Satz _
ca:llista $arrowRight frase _
es:lista $arrowRight frase _
fr:liste $arrowRight phrase _
pt:uma frase com as palavras em _
</translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><custom-block s="join words %mult%txt"><block var="data"/></custom-block></block></script></block-definition><block-definition s="sentence $arrowRight list %'text'" type="reporter" category="operators"><comment x="0" y="0" w="196" collapsed="false">Takes a sentence in text string form and reports the sentence as a list of its words.</comment><header></header><code></code><translations>de:Satz $arrowRight Liste _
ca:frase $arrowRight llista _
es:frase $arrowRight lista _
fr:phrase $arrowRight liste _
pt:uma lista com as palavras da frase _
</translations><inputs><input type="%txt"></input></inputs><script><block s="doReport"><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportNot"><block s="reportEquals"><block s="reportStringSize"><l></l></block><l>0</l></block></block></autolambda><list></list></block><block s="reportTextSplit"><block var="text"/><l><option>word</option></l></block></block></block></script></block-definition><block-definition s="word $arrowRight list %'word'" type="reporter" category="operators"><comment x="0" y="0" w="146.42857142857144" collapsed="false">report a list in which each item is one letter from the input word</comment><header></header><code></code><translations>de:Wort $arrowRight Liste _
ca:paraula $arrowRight llista _
es:palabra $arrowRight lista _
fr:mot $arrowRight liste _
pt:uma lista com os caracteres da palavra _
</translations><inputs><input type="%txt"></input></inputs><script><block s="doIf"><block s="reportIsA"><block var="word"/><l><option>list</option></l></block><script><block s="doReport"><block s="reportMap"><block s="reifyReporter"><autolambda><custom-block s="word $arrowRight list %txt"><l></l></custom-block></autolambda><list></list></block><block var="word"/></block></block></script></block><block s="doReport"><block s="reportTextSplit"><block var="word"/><l><option>letter</option></l></block></block></script></block-definition><block-definition s="list $arrowRight word %'list'" type="reporter" category="operators"><comment x="0" y="0" w="158.57142857142858" collapsed="false">join all the items of the input list
into a single word, and report it</comment><header></header><code></code><translations>de:Liste $arrowRight Wort _
ca:llista $arrowRight paraula _
es:lista $arrowRight palabra _
fr:liste $arrowRight mot _
pt:uma palavra com os caracteres em _
</translations><inputs><input type="%l"></input></inputs><script><block s="doIf"><block s="reportListIsEmpty"><block var="list"/></block><script><block s="doReport"><block var="list"/></block></script></block><block s="doIf"><block s="reportEquals"><block s="reportFindFirst"><block s="reifyPredicate"><autolambda><block s="reportIsA"><l></l><l><option>list</option></l></block></autolambda><list></list></block><block var="list"/></block><l></l></block><script><block s="doReport"><block s="reportJoinWords"><block var="list"/></block></block></script></block><block s="doReport"><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportIfElse"><block s="reportIsA"><l></l><l><option>list</option></l></block><block s="reportNewList"><list><custom-block s="list $arrowRight word %l"><l/></custom-block></list></block><l></l></block></autolambda><list></list></block><block var="list"/></block></block></script></block-definition><block-definition s="sentence %'phrase'" type="reporter" category="lists"><comment w="302.6666666666667" collapsed="false">SENTENCE is the main constructor for sentences, represented
as lists of words. It takes zero or more inputs, each of which can
be either a list or a text string. If a list, the input is assumed to be
a list of words. If a text string, it is converted to a list of words using
SENTENCE→LIST. Then all the lists of words are appended to form a new list of words.

If the inputs are lists of lists rather than lists of words, SENTENCE,
like APPEND, does only one level of flattening, reporting a list of
all the items of all the input lists.</comment><header></header><code></code><translations>ca:frase _
</translations><inputs><input type="%mult%s"></input></inputs><script><block s="doReport"><block s="reportConcatenatedLists"><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportIfElse"><block s="reportIsA"><l></l><l><option>list</option></l></block><l></l><custom-block s="sentence $arrowRight list %txt"><l></l></custom-block></block></autolambda><list></list></block><block var="phrase"/></block></block></block></script></block-definition><block-definition s="error %'msg'" type="command" category="control"><header></header><code></code><translations>pt:lança o erro _
</translations><inputs><input type="%txt"></input></inputs><script><block s="doApplyExtension"><l>err_error(msg)</l><list><block var="msg"/></list></block></script></block-definition><block-definition s="printable %'data'" type="reporter" category="lists"><comment w="188.66666666666666" collapsed="false">Takes a (possibly deep) list as input,
and reports a human-readable text form 
of the list (namely, Lisp notation).</comment><header></header><code></code><translations>ca:notació textual de _
</translations><inputs><input type="%l"></input></inputs><script><block s="doIf"><block s="reportNot"><block s="reportIsA"><block var="data"/><l><option>list</option></l></block></block><script><block s="doReport"><block var="data"/></block></script></block><block s="doIf"><block s="reportListIsEmpty"><block var="data"/></block><script><block s="doReport"><l>()</l></block></script></block><block s="doReport"><block s="reportJoinWords"><list><l>(</l><block s="reportCombine"><block s="reportMap"><block s="reifyReporter"><autolambda><custom-block s="printable %l"><l/></custom-block></autolambda><list></list></block><block var="data"/></block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><l></l><l> </l><l></l></list></block></autolambda><list></list></block></block><l>)</l></list></block></block></script></block-definition><block-definition s="require nonempty %'text' %'message'" type="reporter" category="operators" helper="true"><comment x="0" y="0" w="220" collapsed="false">Helper function for word/sentence library.
Reports its first input, unless that input is empty, in which case it gives its second input as an error message.</comment><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doIfElse"><block s="reportIfElse"><block s="reportIsA"><block var="text"/><l><option>list</option></l></block><block s="reportListIsEmpty"><block var="text"/></block><block s="reportEquals"><block s="reportStringSize"><block var="text"/></block><l>0</l></block></block><script><custom-block s="error %txt"><block var="message"/></custom-block></script><script><block s="doReport"><block var="text"/></block></script></block></script></block-definition><block-definition s="first letter of %'word'" type="reporter" category="operators"><comment w="260" collapsed="false">Takes a text string as input, and reports the first character in the string.</comment><header></header><code></code><translations>pt:a primeira palavra de _
ca:primera lletra de _
</translations><inputs><input type="%txt"></input></inputs><script><block s="doIfElse"><block s="reportIsA"><block var="word"/><l><option>list</option></l></block><script><block s="doReport"><block s="reportMap"><block s="reifyReporter"><autolambda><custom-block s="first letter of %txt"><l></l></custom-block></autolambda><list></list></block><block var="word"/></block></block></script><script><block s="doReport"><block s="reportLetter"><l>1</l><custom-block s="require nonempty %s %s"><block var="word"/><l>First of empty word.</l></custom-block></block></block></script></block></script></block-definition></blocks> |