Anonymous user
Copy a string: Difference between revisions
added Ol
(added Ol) |
|||
Line 1,718:
There is no need to copy a string content as strings are immutable. If really needed :
<lang Oforth>StringBuffer new "abcde" << </lang>
=={{header|Ol}}==
<lang scheme>
(define a "The String.")
; copy the string
(define b (runes->string (string->runes a)))
(print "a: " a)
(print "b: " b)
(print "b is an a: " (eq? a b))
(print "b same as a: " (equal? a b))
; another way: marshal the string
(define c (fasl-decode (fasl-encode a) #f))
(print "a: " a)
(print "c: " c)
(print "c is an a: " (eq? a c))
(print "c same as a: " (equal? a c))
</lang>
{{Out}}
<pre>
a: The String.
b: The String.
b is an a: #false
b same as a: #true
a: The String.
c: The String.
c is an a: #false
c same as a: #true
</pre>
=={{header|ooRexx}}==
|