Odd word problem: Difference between revisions
Content added Content deleted
(Added Quackery.) |
(→{{header|Quackery}}: removed test for end of string) |
||
Line 2,261: | Line 2,261: | ||
It is not possible to comply with the requirements of this task ''to the letter'' as the task presumes the existence of an ''implicit'' stack, e.g. a stack frame storing state information during subroutine calls, including recursive calls. In Quackery such information is stored on a second stack (usually referred to as ''the stack'') which is ''explicit''. |
It is not possible to comply with the requirements of this task ''to the letter'' as the task presumes the existence of an ''implicit'' stack, e.g. a stack frame storing state information during subroutine calls, including recursive calls. In Quackery such information is stored on a second stack (usually referred to as ''the stack'') which is ''explicit''. |
||
Also, there is no character-at-a-time input stream mechanism implemented in Quackery. |
Also, there is no character-at-a-time input stream mechanism implemented in Quackery. Instead, the code uses the word <code>behead</code> which equivalently returns successive characters from a string, one at a time. |
||
Therefore this solution is in the spirit of the requirements, if not the letter. |
Therefore this solution is in the spirit of the requirements, if not the letter. |
||
<lang Quackery>[ upper dup lower != ] |
<lang Quackery>[ upper dup lower != ] is letter ( c --> b ) |
||
forward is backwords ( $ --> $ ) |
|||
[ [ behead |
|||
[ dup $ "" = if done |
|||
dup letter while |
|||
emit again ] |
emit again ] |
||
dup emit |
|||
⚫ | |||
char . != |
|||
⚫ | |||
[ [ behead |
|||
[ dup $ "" = if done |
|||
dup letter while |
|||
swap recurse |
swap recurse |
||
rot emit ] |
rot emit ] |
||
dup emit |
|||
⚫ | |||
char . != |
|||
⚫ | |||
[ forwords drop cr ] |
[ forwords drop cr ] is oddwords ( $ --> ) |
||
$ "we,are;not,in,kansas;any,more." oddwords |
$ "we,are;not,in,kansas;any,more." oddwords |