String matching: Difference between revisions
Content deleted Content added
Logo |
Added PicoLisp |
||
Line 171: | Line 171: | ||
$loc = index("abab", "ab") #returns 0 |
$loc = index("abab", "ab") #returns 0 |
||
$loc = index("abab", "ab", $loc+1) #returns 2</lang> |
$loc = index("abab", "ab", $loc+1) #returns 2</lang> |
||
=={{header|PicoLisp}}== |
|||
<lang PicoLisp>: (pre? "ab" "abcd") |
|||
-> "abcd" |
|||
: (pre? "xy" "abcd") |
|||
-> NIL |
|||
: (sub? "bc" "abcd") |
|||
-> "abcd" |
|||
: (sub? "xy" "abcd") |
|||
-> NIL |
|||
: (tail (chop "cd") (chop "abcd")) |
|||
-> ("c" "d") |
|||
: (tail (chop "xy") (chop "abcd")) |
|||
-> NIL |
|||
(de positions (Pat Str) |
|||
(setq Pat (chop Pat)) |
|||
(make |
|||
(for ((I . L) (chop Str) L (cdr L)) |
|||
(and (head Pat L) (link I)) ) ) ) |
|||
: (positions "bc" "abcdabcd") |
|||
-> (2 6)</lang> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |