Idiomatically determine all the characters that can be used for symbols: Difference between revisions
Content added Content deleted
m (racket BEFORE rexx!) |
|||
Line 161: | Line 161: | ||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
[http://docs.racket-lang.org/guide/symbols.html Symbols in the Racket Guide] states that: |
|||
⚫ | |||
<blockquote>Any string (i.e., any character sequence) can be supplied to <code>string->symbol</code> to obtain |
|||
the corresponding symbol.</blockquote> |
|||
[http://docs.racket-lang.org/reference/reader.html#%28part._parse-symbol%29 Reading Symbols] defines |
|||
what symbols can be "read" without needing quoting. |
|||
The docuementation for |
|||
[http://docs.racket-lang.org/reference/characters.html#%28def._%28%28quote._~23~25kernel%29._integer-~3echar%29%29 <code>integer->char</code>] |
|||
says that a character must lie in the ranges: 0 to 55295, and 57344 to 1114111. |
|||
That's too much to be printing out here... call <code>(main)</code> yourself, at home. |
|||
⚫ | |||
;; Symbols that don't need to be specially quoted: |
|||
(printf "~s~%" '(a a-z 3rd ...---... .hidden-files-look-like-this)) |
|||
;; Symbols that do need to be specially quoted: |
|||
(define bar-sym-list |
|||
`(|3| |
|||
|i have a space| |
|||
|i've got a quote in me| |
|||
|i'm not a "dot on my own", but my neighbour is!| |
|||
|.| |
|||
,(string->symbol "\u03bb") |
|||
,(string->symbol "my characters aren't even mapped in unicode \U10e443"))) |
|||
(printf "~s~%" bar-sym-list) |
|||
(printf "~a~%" bar-sym-list) |
|||
(define (main) |
|||
(for |
|||
((c (sequence-map |
|||
integer->char |
|||
(in-sequences (in-range 0 (add1 55295)) |
|||
(in-range 57344 (add1 1114111))))) |
|||
(i (in-naturals 1))) |
|||
(when (zero? (modulo i 80)) (newline)) |
|||
(display (list->string (list c))))) |
|||
</lang> |
</lang> |
||
{{out}} |
{{out}} |
||
<pre>(a a-z 3rd ...---... .hidden-files-look-like-this) |
|||
<pre> |
|||
(|3| |i have a space| |i've got a quote in me| |i'm not a "dot on my own", but my neighbour is!| |.| λ |my characters aren't even mapped in unicode |) |
|||
</pre> |
|||
(3 i have a space i've got a quote in me i'm not a "dot on my own", but my neighbour is! . λ my characters aren't even mapped in unicode )</pre> |
|||
The output to <code>(main)</code> is massive, and probably not dissimilar to Tcl's (anyone want to compare?) |
The output to <code>(main)</code> is massive, and probably not dissimilar to Tcl's (anyone want to compare?) |
||