[svn:parrot] r46103 - in trunk/examples: pir/befunge tutorial
jimmy at svn.parrot.org
jimmy at svn.parrot.org
Wed Apr 28 04:34:24 UTC 2010
Author: jimmy
Date: Wed Apr 28 04:34:24 2010
New Revision: 46103
URL: https://trac.parrot.org/parrot/changeset/46103
Log:
replace/modify in-place string ops
Modified:
trunk/examples/pir/befunge/debug.pir
trunk/examples/pir/befunge/io.pir
trunk/examples/pir/befunge/load.pir
trunk/examples/tutorial/23_string_ops_substr.pir
Modified: trunk/examples/pir/befunge/debug.pir
==============================================================================
--- trunk/examples/pir/befunge/debug.pir Wed Apr 28 04:17:55 2010 (r46102)
+++ trunk/examples/pir/befunge/debug.pir Wed Apr 28 04:34:24 2010 (r46103)
@@ -205,7 +205,7 @@
goto DEBUG__INTERACT__LOOP
DEBUG__INTERACT__BREAK:
- substr $S0, 0, 6, ""
+ $S0 = replace $S0, 0, 6, ""
$P0 = get_global "breakpoints"
$P0[$S0] = 1
set_global "breakpoints", $P0
@@ -218,7 +218,7 @@
goto DEBUG__INTERACT__END
DEBUG__INTERACT__DELETE:
- substr $S0, 0, 7, ""
+ $S0 = replace $S0, 0, 7, ""
$P0 = get_global "breakpoints"
delete $P0[$S0]
set_global "breakpoints", $P0
Modified: trunk/examples/pir/befunge/io.pir
==============================================================================
--- trunk/examples/pir/befunge/io.pir Wed Apr 28 04:17:55 2010 (r46102)
+++ trunk/examples/pir/befunge/io.pir Wed Apr 28 04:34:24 2010 (r46103)
@@ -44,7 +44,7 @@
chopn $S0, 1
_IO__INPUT_CHAR__SUBSTR:
- $S1 = substr $S0, 0, 1, ""
+ $S1 = replace $S0, 0, 1, ""
$P0 = $S0
set_global "user_input", $P0
@@ -90,7 +90,7 @@
if i < len goto _IO__INPUT_INT__NEXT_CHAR
_IO__INPUT_INT__NAN:
- substr $S0, 0, i, ""
+ $S = replace $S0, 0, i, ""
$P0 = $S0
set_global "user_input", $P0
Modified: trunk/examples/pir/befunge/load.pir
==============================================================================
--- trunk/examples/pir/befunge/load.pir Wed Apr 28 04:17:55 2010 (r46102)
+++ trunk/examples/pir/befunge/load.pir Wed Apr 28 04:34:24 2010 (r46103)
@@ -86,7 +86,7 @@
concat str, $S0
# truncate to 80 chars
- substr str, 80, -1, ''
+ str = replace str, 80, -1, ''
.return(str)
.end
Modified: trunk/examples/tutorial/23_string_ops_substr.pir
==============================================================================
--- trunk/examples/tutorial/23_string_ops_substr.pir Wed Apr 28 04:17:55 2010 (r46102)
+++ trunk/examples/tutorial/23_string_ops_substr.pir Wed Apr 28 04:34:24 2010 (r46103)
@@ -10,9 +10,6 @@
position is left out, C<substr> returns all the characters until the
end of the string.
-An optional fourth argument is a string that will be used to
-replace the characters between the start and end positions.
-
=cut
.sub main :main
@@ -25,11 +22,6 @@
say $S0 # "bc"
say $S1 # "abcde"
- set $S1, "abcde"
- $S0 = substr $S1, 1, 2, "XYZ"
- say $S0 # "bc"
- say $S1 # "aXYZde"
-
.end
# Local Variables:
More information about the parrot-commits
mailing list