Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/Tokenize-a-string/Pop11/tokenize-a-string-1.pop11
Normal file
6
Task/Tokenize-a-string/Pop11/tokenize-a-string-1.pop11
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
;;; Make a list of strings from a string using space as separator
|
||||
lvars list;
|
||||
sysparse_string('the cat sat on the mat') -> list;
|
||||
;;; print the list of strings
|
||||
list =>
|
||||
** [the cat sat on the mat]
|
||||
10
Task/Tokenize-a-string/Pop11/tokenize-a-string-2.pop11
Normal file
10
Task/Tokenize-a-string/Pop11/tokenize-a-string-2.pop11
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
lvars list;
|
||||
sysparse_string('one 1 two 2 three 3 four 4', true) -> list;
|
||||
;;; print the list of strings and numbers
|
||||
list =>
|
||||
** [one 1 two 2 three 3 four 4]
|
||||
;;; check that first item is a string and second an integer
|
||||
isstring(list(1))=>
|
||||
** <true>
|
||||
isinteger(list(2))=>
|
||||
** <true>
|
||||
15
Task/Tokenize-a-string/Pop11/tokenize-a-string-3.pop11
Normal file
15
Task/Tokenize-a-string/Pop11/tokenize-a-string-3.pop11
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
;;; Make pop-11 print strings with quotes
|
||||
true -> pop_pr_quotes;
|
||||
;;;
|
||||
;;; Create a string of tokens using comma as token separator
|
||||
lvars str='Hello,How,Are,You,Today';
|
||||
;;;
|
||||
;;; Make a list of strings by applying sys_parse_string
|
||||
;;; to str, using the character `,` as separator (the default
|
||||
;;; separator, if none is provided, is the space character).
|
||||
lvars strings;
|
||||
[% sys_parse_string(str, `,`) %] -> strings;
|
||||
;;;
|
||||
;;; print the list of strings
|
||||
strings =>
|
||||
** ['Hello' 'How' 'Are' 'You' 'Today']
|
||||
4
Task/Tokenize-a-string/Pop11/tokenize-a-string-4.pop11
Normal file
4
Task/Tokenize-a-string/Pop11/tokenize-a-string-4.pop11
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{% sys_parse_string(str, `,`) %} -> strings;
|
||||
;;; print the vector
|
||||
strings =>
|
||||
** {'Hello' 'How' 'Are' 'You' 'Today'}
|
||||
6
Task/Tokenize-a-string/Pop11/tokenize-a-string-5.pop11
Normal file
6
Task/Tokenize-a-string/Pop11/tokenize-a-string-5.pop11
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
lvars numbers;
|
||||
{% sys_parse_string('100 101 102 103 99.9 99.999', strnumber) %} -> numbers;
|
||||
;;; the result is a vector containing integers and floats,
|
||||
;;; which can be printed thus:
|
||||
numbers =>
|
||||
** {100 101 102 103 99.9 99.999}
|
||||
18
Task/Tokenize-a-string/Pop11/tokenize-a-string-6.pop11
Normal file
18
Task/Tokenize-a-string/Pop11/tokenize-a-string-6.pop11
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
;;; Declare and initialize variables
|
||||
lvars str='Hello,How,Are,You,Today';
|
||||
;;; Iterate over string
|
||||
lvars ls = [], i, j = 1;
|
||||
for i from 1 to length(str) do
|
||||
;;; If comma
|
||||
if str(i) = `,` then
|
||||
;;; Prepend word (substring) to list
|
||||
cons(substring(j, i - j, str), ls) -> ls;
|
||||
i + 1 -> j;
|
||||
endif;
|
||||
endfor;
|
||||
;;; Prepend final word (if needed)
|
||||
if j <= length(str) then
|
||||
cons(substring(j, length(str) - j + 1, str), ls) -> ls;
|
||||
endif;
|
||||
;;; Reverse the list
|
||||
rev(ls) -> ls;
|
||||
9
Task/Tokenize-a-string/Pop11/tokenize-a-string-7.pop11
Normal file
9
Task/Tokenize-a-string/Pop11/tokenize-a-string-7.pop11
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
;;; Put list elements and lenght on the stack
|
||||
destlist(ls);
|
||||
;;; Build a vector from them
|
||||
lvars ar = consvector();
|
||||
;;; Display in a loop, putting trailing period
|
||||
for i from 1 to length(ar) do
|
||||
printf(ar(i), '%s.');
|
||||
endfor;
|
||||
printf('\n');
|
||||
3
Task/Tokenize-a-string/Pop11/tokenize-a-string-8.pop11
Normal file
3
Task/Tokenize-a-string/Pop11/tokenize-a-string-8.pop11
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i in ls do
|
||||
printf(i, '%s.');
|
||||
endfor;
|
||||
Loading…
Add table
Add a link
Reference in a new issue