Skip to content

Instantly share code, notes, and snippets.

@meijeru
Last active November 21, 2019 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meijeru/f5cf9fccb1f3cf2e9d017c59ebf6f93f to your computer and use it in GitHub Desktop.
Save meijeru/f5cf9fccb1f3cf2e9d017c59ebf6f93f to your computer and use it in GitHub Desktop.
string-conversion table
<h3>String conversions</h3>
<table border=0 cellspacing=1 cellpadding=5 bgcolor=gray>
<tr>
<th>type</th>
<th>expression</th>
<th>to-string</th>
<th>form</th>
<th>mold</th>
<th>mold/all</th>
</tr>
<tr bgcolor="white">
<th>unset!</th>
<th>( )</th>
<td>
<em>error</em>
</td>
<td>
<em>empty string</em>
</td>
<td>
unset
</td>
<td>
unset
</td>
</tr>
<tr bgcolor="white">
<th>none!</th>
<th>#[none]</th>
<td>
<em>error</em>
</td>
<td>
none
</td>
<td>
none
</td>
<td>
none
</td>
</tr>
<tr bgcolor="white">
<th>logic!</th>
<th>#[true]</th>
<td>
true
</td>
<td>
true
</td>
<td>
true
</td>
<td>
true
</td>
</tr>
<tr bgcolor="white">
<th>char!</th>
<th>#"a"</th>
<td>
a
</td>
<td>
a
</td>
<td>
#"a"
</td>
<td>
#"a"
</td>
</tr>
<tr bgcolor="white">
<th>integer!</th>
<th>123</th>
<td>
123
</td>
<td>
123
</td>
<td>
123
</td>
<td>
123
</td>
</tr>
<tr bgcolor="white">
<th>float!</th>
<th>123.456</th>
<td>
123.456
</td>
<td>
123.456
</td>
<td>
123.456
</td>
<td>
123.456
</td>
</tr>
<tr bgcolor="white">
<th>percent!</th>
<th>50%</th>
<td>
50%
</td>
<td>
50%
</td>
<td>
50%
</td>
<td>
50%
</td>
</tr>
<tr bgcolor="white">
<th>pair!</th>
<th>1x2</th>
<td>
1x2
</td>
<td>
1x2
</td>
<td>
1x2
</td>
<td>
1x2
</td>
</tr>
<tr bgcolor="white">
<th>tuple!</th>
<th>1.2.3</th>
<td>
1.2.3
</td>
<td>
1.2.3
</td>
<td>
1.2.3
</td>
<td>
1.2.3
</td>
</tr>
<tr bgcolor="white">
<th>date!</th>
<th>now/date</th>
<td>
9-Jun-2018
</td>
<td>
9-Jun-2018
</td>
<td>
9-Jun-2018
</td>
<td>
9-Jun-2018
</td>
</tr>
<tr bgcolor="white">
<th>time!</th>
<th>now/time</th>
<td>
11:42:20
</td>
<td>
11:42:20
</td>
<td>
11:42:20
</td>
<td>
11:42:20
</td>
</tr>
<tr bgcolor="white">
<th>word!</th>
<th>'abc</th>
<td>
abc
</td>
<td>
abc
</td>
<td>
abc
</td>
<td>
abc
</td>
</tr>
<tr bgcolor="white">
<th>set-word!</th>
<th>quote abc:</th>
<td>
abc
</td>
<td>
abc
</td>
<td>
abc:
</td>
<td>
abc:
</td>
</tr>
<tr bgcolor="white">
<th>lit-word!</th>
<th>quote 'abc</th>
<td>
abc
</td>
<td>
abc
</td>
<td>
'abc
</td>
<td>
'abc
</td>
</tr>
<tr bgcolor="white">
<th>get-word!</th>
<th>quote :abc</th>
<td>
abc
</td>
<td>
abc
</td>
<td>
:abc
</td>
<td>
:abc
</td>
</tr>
<tr bgcolor="white">
<th>refinement!</th>
<th>/abc</th>
<td>
abc
</td>
<td>
abc
</td>
<td>
/abc
</td>
<td>
/abc
</td>
</tr>
<tr bgcolor="white">
<th>issue!</th>
<th>#abc</th>
<td>
abc
</td>
<td>
abc
</td>
<td>
#abc
</td>
<td>
#abc
</td>
</tr>
<tr bgcolor="white">
<th>block!</th>
<th>[1 2 3]</th>
<td>
123
</td>
<td>
1 2 3
</td>
<td>
[1 2 3]
</td>
<td>
[1 2 3]
</td>
</tr>
<tr bgcolor="white">
<th>paren!</th>
<th>quote (1 2 3)</th>
<td>
123
</td>
<td>
1 2 3
</td>
<td>
(1 2 3)
</td>
<td>
(1 2 3)
</td>
</tr>
<tr bgcolor="white">
<th>hash!</th>
<th>make hash! [1 2 3]</th>
<td>
123
</td>
<td>
1 2 3
</td>
<td>
make hash! ...
</td>
<td>
make hash! ...
</td>
</tr>
<tr bgcolor="white">
<th>path!</th>
<th>'a/b/c</th>
<td>
a/b/c
</td>
<td>
a/b/c
</td>
<td>
a/b/c
</td>
<td>
a/b/c
</td>
</tr>
<tr bgcolor="white">
<th>lit-path!</th>
<th>quote 'a/b/c</th>
<td>
'a/b/c
</td>
<td>
'a/b/c
</td>
<td>
'a/b/c
</td>
<td>
'a/b/c
</td>
</tr>
<tr bgcolor="white">
<th>set-path!</th>
<th>quote a/b/c:</th>
<td>
a/b/c:
</td>
<td>
a/b/c:
</td>
<td>
a/b/c:
</td>
<td>
a/b/c:
</td>
</tr>
<tr bgcolor="white">
<th>get-path!</th>
<th>quote :a/b/c</th>
<td>
:a/b/c
</td>
<td>
:a/b/c
</td>
<td>
:a/b/c
</td>
<td>
:a/b/c
</td>
</tr>
<tr bgcolor="white">
<th>string!</th>
<th>"abc"</th>
<td>
abc
</td>
<td>
abc
</td>
<td>
"abc"
</td>
<td>
"abc"
</td>
</tr>
<tr bgcolor="white">
<th>file!</th>
<th>%abc.def</th>
<td>
abc.def
</td>
<td>
abc.def
</td>
<td>
%abc.def
</td>
<td>
%abc.def
</td>
</tr>
<tr bgcolor="white">
<th>url!</th>
<th>http://abc.def</th>
<td>
http://abc.def
</td>
<td>
http://abc.def
</td>
<td>
http://abc.def
</td>
<td>
http://abc.def
</td>
</tr>
<tr bgcolor="white">
<th>tag!</th>
<th>&lt;a href="red-lang.org"&gt;</th>
<td>
a href="red-lang.org"
</td>
<td>
&lt;a href="red-lang.org"&gt;
</td>
<td>
&lt;a href="red-lang.org"&gt;
</td>
<td>
&lt;a href="red-lang.org"&gt;
</td>
</tr>
<tr bgcolor="white">
<th>email!</th>
<th>user@host.com</th>
<td>
user@host.com
</td>
<td>
user@host.com
</td>
<td>
user@host.com
</td>
<td>
user@host.com
</td>
</tr>
<tr bgcolor="white">
<th>vector!</th>
<th>make vector! [1 2 3]</th>
<td>
1 2 3
</td>
<td>
1 2 3
</td>
<td>
make vector! ...
</td>
<td>
make vector! ...
</td>
</tr>
<tr bgcolor="white">
<th>image!</th>
<th>make image! 2x2</th>
<td>
make image! ...
</td>
<td>
make image! ...
</td>
<td>
make image! ...
</td>
<td>
make image! ...
</td>
</tr>
<tr bgcolor="white">
<th>binary!</th>
<th>#{313233}</th>
<td>
123
</td>
<td>
#{313233}
</td>
<td>
#{313233}
</td>
<td>
#{313233}
</td>
</tr>
<tr bgcolor="white">
<th>bitset!</th>
<th>charset "abc"</th>
<td>
make bitset! ...
</td>
<td>
make bitset! ...
</td>
<td>
make bitset! ...
</td>
<td>
make bitset! ...
</td>
</tr>
<tr bgcolor="white">
<th>map!</th>
<th>#(a: 1 b: 2)</th>
<td>
a: 1
b: 2
</td>
<td>
a: 1
b: 2
</td>
<td>
#(
a: 1
b: 2
)
</td>
<td>
#(
a: 1
b: 2
)
</td>
</tr>
<tr bgcolor="white">
<th>object!</th>
<th>object [a: 1 b: 2]</th>
<td>
a: 1
b: 2
</td>
<td>
a: 1
b: 2
</td>
<td>
make object! ...
</td>
<td>
make object! ...
</td>
</tr>
<tr bgcolor="white">
<th>error!</th>
<th>try [1 / 0]</th>
<td>
*** Math Error: ...
</td>
<td>
*** Math Error: ...
</td>
<td>
make error! ...
</td>
<td>
make error! ...
</td>
</tr>
<tr bgcolor="white">
<th>native!</th>
<th>:if</th>
<td>
?native?
</td>
<td>
?native?
</td>
<td>
make native! ...
</td>
<td>
make native! ...
</td>
</tr>
<tr bgcolor="white">
<th>action!</th>
<th>:add</th>
<td>
?action?
</td>
<td>
?action?
</td>
<td>
make action! ...
</td>
<td>
make action! ...
</td>
</tr>
<tr bgcolor="white">
<th>op!</th>
<th>:+</th>
<td>
?op?
</td>
<td>
?op?
</td>
<td>
make op! ...
</td>
<td>
make op! ...
</td>
</tr>
<tr bgcolor="white">
<th>function!</th>
<th>func [a b][a + b]</th>
<td>
?function?
</td>
<td>
?function?
</td>
<td>
func[...][...]
</td>
<td>
func[...][...]
</td>
</tr>
<tr bgcolor="white">
<th>routine!</th>
<th>:event?</th>
<td>
?routine?
</td>
<td>
?routine?
</td>
<td>
routine[...][...]
</td>
<td>
routine[...][...]
</td>
</tr>
<tr bgcolor="white">
<th>datatype!</th>
<th>action!</th>
<td>
action
</td>
<td>
action
</td>
<td>
action!
</td>
<td>
action!
</td>
</tr>
<tr bgcolor="white">
<th>typeset!</th>
<th>number!</th>
<td>
make typeset! ...
</td>
<td>
make typeset! ...
</td>
<td>
make typeset! ...
</td>
<td>
make typeset! ...
</td>
</tr>
</table>
@hiiamboris
Copy link

GH doesn't render it. I'll just copy it into the comment so I may see it ☻

String conversions

type expression to-string form mold mold/all
unset! ( ) error empty string unset unset
none! #[none] error none none none
logic! #[true] true true true true
char! #"a" a a #"a" #"a"
integer! 123 123 123 123 123
float! 123.456 123.456 123.456 123.456 123.456
percent! 50% 50% 50% 50% 50%
pair! 1x2 1x2 1x2 1x2 1x2
tuple! 1.2.3 1.2.3 1.2.3 1.2.3 1.2.3
date! now/date 9-Jun-2018 9-Jun-2018 9-Jun-2018 9-Jun-2018
time! now/time 11:42:20 11:42:20 11:42:20 11:42:20
word! 'abc abc abc abc abc
set-word! quote abc: abc abc abc: abc:
lit-word! quote 'abc abc abc 'abc 'abc
get-word! quote :abc abc abc :abc :abc
refinement! /abc abc abc /abc /abc
issue! #abc abc abc #abc #abc
block! [1 2 3] 123 1 2 3 [1 2 3] [1 2 3]
paren! quote (1 2 3) 123 1 2 3 (1 2 3) (1 2 3)
hash! make hash! [1 2 3] 123 1 2 3 make hash! ... make hash! ...
path! 'a/b/c a/b/c a/b/c a/b/c a/b/c
lit-path! quote 'a/b/c 'a/b/c 'a/b/c 'a/b/c 'a/b/c
set-path! quote a/b/c: a/b/c: a/b/c: a/b/c: a/b/c:
get-path! quote :a/b/c :a/b/c :a/b/c :a/b/c :a/b/c
string! "abc" abc abc "abc" "abc"
file! %abc.def abc.def abc.def %abc.def %abc.def
url! http://abc.def http://abc.def http://abc.def http://abc.def http://abc.def
tag! <a href="red-lang.org"> a href="red-lang.org" <a href="red-lang.org"> <a href="red-lang.org"> <a href="red-lang.org">
email! user@host.com user@host.com user@host.com user@host.com user@host.com
vector! make vector! [1 2 3] 1 2 3 1 2 3 make vector! ... make vector! ...
image! make image! 2x2 make image! ... make image! ... make image! ... make image! ...
binary! #{313233} 123 #{313233} #{313233} #{313233}
bitset! charset "abc" make bitset! ... make bitset! ... make bitset! ... make bitset! ...
map! #(a: 1 b: 2) a: 1 b: 2 a: 1 b: 2 #( a: 1 b: 2 ) #( a: 1 b: 2 )
object! object [a: 1 b: 2] a: 1 b: 2 a: 1 b: 2 make object! ... make object! ...
error! try [1 / 0] *** Math Error: ... *** Math Error: ... make error! ... make error! ...
native! :if ?native? ?native? make native! ... make native! ...
action! :add ?action? ?action? make action! ... make action! ...
op! :+ ?op? ?op? make op! ... make op! ...
function! func [a b][a + b] ?function? ?function? func[...][...] func[...][...]
routine! :event? ?routine? ?routine? routine[...][...] routine[...][...]
datatype! action! action action action! action!
typeset! number! make typeset! ... make typeset! ... make typeset! ... make typeset! ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment