Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,3 +1,5 @@
|
|||
Show literal specification of characters and strings. If supported, show how verbatim strings (quotes where escape sequences are quoted literally) and here-strings work. Also, discuss which quotes expand variables.
|
||||
Show literal specification of characters and strings.
|
||||
If supported, show how verbatim strings (quotes where escape sequences are quoted literally) and here-strings work.
|
||||
Also, discuss which quotes expand variables.
|
||||
|
||||
* Related tasks: [[Special characters]], [[Here document]]
|
||||
|
|
|
|||
|
|
@ -1,2 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- String manipulation
|
||||
- Syntax elements
|
||||
note: Basic language learning
|
||||
|
|
|
|||
1
Task/Literals-String/Emacs-Lisp/literals-string-1.l
Normal file
1
Task/Literals-String/Emacs-Lisp/literals-string-1.l
Normal file
|
|
@ -0,0 +1 @@
|
|||
"This is a string."
|
||||
2
Task/Literals-String/Emacs-Lisp/literals-string-2.l
Normal file
2
Task/Literals-String/Emacs-Lisp/literals-string-2.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
?z => 122
|
||||
?\n => 10
|
||||
|
|
@ -1 +1,6 @@
|
|||
ch := 'z'
|
||||
ch = 122 // or 0x7a or 0172 or any other integer literal
|
||||
ch = '\x7a' // \x{2*hex}
|
||||
ch = '\u007a' // \u{4*hex}
|
||||
ch = '\U0000007a' // \U{8*hex}
|
||||
ch = '\172' // \{3*octal}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
ch := 'z' // by default, ch takes type int32
|
||||
var r rune = 'z' // reflect.TypeOf(r) still returns int32
|
||||
var b byte = 'z' // reflect.TypeOf(b) returns uint8
|
||||
ch := 'z' // ch is type rune (an int32 type)
|
||||
var r rune = 'z' // r is type rune
|
||||
var b byte = 'z' // b is type byte (an uint8 type)
|
||||
b2 := byte('z') // equivalent to b
|
||||
const c byte = 'z' // c is now a "typed constant"
|
||||
const z = 'z' // z is untyped, it may be freely assigned or used in any integer expression
|
||||
b = z
|
||||
r = z
|
||||
ch2 := z // equivalent to ch (type rune)
|
||||
var i int = z
|
||||
const c byte = 'z' // c is a typed constant
|
||||
b = c
|
||||
r = rune(c)
|
||||
i = int(c)
|
||||
b3 := c // equivalent to b
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
str := "z"
|
||||
str = "\u007a"
|
||||
str = "two\nlines"
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
`abc
|
||||
def` == "abc\ndef"
|
||||
def` == "abc\ndef", // never "abc\r\ndef" even if the source file contains CR+LF line endings
|
||||
|
|
|
|||
|
|
@ -1,16 +1,7 @@
|
|||
It's also possible to express characters in hexadecimal notation in a string:
|
||||
lf = '0A'x
|
||||
cr = '0D'x
|
||||
|
||||
mmm='01 02 03 34 ee'x
|
||||
ppp='dead beaf 11112222 33334444 55556666 77778888 00009999 c0ffee'X
|
||||
mmm = '01 02 03 34 ee'x
|
||||
ppp = 'dead beaf 11112222 33334444 55556666 77778888 00009999 c0ffee'X
|
||||
|
||||
lang='52455858'x /*which is "REXX" on ASCII-computers.*/
|
||||
|
||||
Binary strings are also possible:
|
||||
|
||||
jjj='01011011'B
|
||||
jjj='01011011'b
|
||||
jjj="0101 1011"b
|
||||
jjj='0101 1011 1111'b
|
||||
longjjj='11110000 10100001 10110010 11100011 11100100'B
|
||||
lang = '52455858'x /*which is "REXX" on ASCII-computers.*/
|
||||
|
|
|
|||
5
Task/Literals-String/REXX/literals-string-4.rexx
Normal file
5
Task/Literals-String/REXX/literals-string-4.rexx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
jjj = '01011011'B
|
||||
jjj = '01011011'b
|
||||
jjj = "0101 1011"b
|
||||
jjj = '0101 1011 1111'b
|
||||
longjjj = '11110000 10100001 10110010 11100011 11100100'B
|
||||
Loading…
Add table
Add a link
Reference in a new issue