Copy a string: Difference between revisions
Content deleted Content added
Added Haskell example |
Logo |
||
Line 251: | Line 251: | ||
(eq orig copied) |
(eq orig copied) |
||
nil |
nil |
||
=={{header|Logo}}== |
|||
As a functional language, words are normally treated as symbols and cannot be modified. The EQUAL? predicate compares contents instead of identity. In [[UCB Logo]] the .EQ predicate tests for "thing" identity. |
|||
make "a "foo |
|||
make "b "foo |
|||
print .eq :a :b ; true, identical symbols are reused |
|||
make "c :a |
|||
print .eq :a :c ; true, copy a reference |
|||
make "c word :b "|| ; force a copy of the contents of a word by appending the empty word |
|||
print equal? :b :c ; true |
|||
print .eq? :b :c ; false |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |