summaryrefslogtreecommitdiffhomepage
path: root/golfscript.html.markdown
diff options
context:
space:
mode:
authorNicholas Georgescu <36280690+NGeorgescu@users.noreply.github.com>2024-05-14 18:47:58 -0400
committerGitHub <noreply@github.com>2024-05-14 16:47:58 -0600
commit8ceeec19fdcf662f3ac02593944308cce33a15ac (patch)
treececdb695d03ff5d88c31c38b669801d1f2e36885 /golfscript.html.markdown
parentbb91dc603bbe2c24adda27933a22b1f850003778 (diff)
[golfscript/en-en] Add some nifty string tricks (#4945)
Diffstat (limited to 'golfscript.html.markdown')
-rw-r--r--golfscript.html.markdown13
1 files changed, 12 insertions, 1 deletions
diff --git a/golfscript.html.markdown b/golfscript.html.markdown
index 8ea985e8..f4b88a9f 100644
--- a/golfscript.html.markdown
+++ b/golfscript.html.markdown
@@ -242,7 +242,18 @@ I drive a stick, BTW.
[]
> '22222'{+}* # note that if you fold-sum a string not in an array, you'll
# get the sum of the ascii values. '2' is 50, so five times that is:
-250
+[250]
+> ]; # this actually is a clever trick to get ascii values into an array.
+[]
+> "aabc" [{""+~}*] # if you fold over addition and drop it into a string:
+[[97 97 98 99]]
+> {[.]""^}%""+ # which can be returned to a string as such using a ""^ map.
+# and an empty string join.
+["aabc"]
+> {32-}% # note that most mapping operations work on the ascii values as
+# you would expect, for instance with the difference between A and a being
+# 32, you can just subtract that from the ascii value to get:
+["AABC"]
> ]; ###################################################################
# blocks
########################################################################