Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Quoting-constructs/Nim/quoting-constructs.nim
Normal file
38
Task/Quoting-constructs/Nim/quoting-constructs.nim
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
echo "A simple string."
|
||||
echo "A simple string including tabulation special character \\t: \t."
|
||||
|
||||
echo """
|
||||
First part of a multiple string,
|
||||
followed by second part
|
||||
and third part.
|
||||
"""
|
||||
|
||||
echo r"A raw string containing a \."
|
||||
|
||||
# Interpolation in strings.
|
||||
import strformat
|
||||
const C = "constant"
|
||||
const S = fmt"A string with interpolation of a {C}."
|
||||
echo S
|
||||
var x = 3
|
||||
echo fmt"A string with interpolation of expression “2 * x + 3”: {2 * x + 3}."
|
||||
echo fmt"Displaying “x” with an embedded format: {x:05}."
|
||||
|
||||
# Regular expression string.
|
||||
import re
|
||||
let r = re"\d+"
|
||||
|
||||
# Pegs string.
|
||||
import pegs
|
||||
let e = peg"\d+"
|
||||
|
||||
# Array literal.
|
||||
echo [1, 2, 3] # Element type if implicit ("int" here).
|
||||
echo [byte(1), 2, 3] # Element type is specified by the first element type.
|
||||
echo [byte 1, 2, 3] # An equivalent way to specify the type.
|
||||
|
||||
echo @[1, 2, 3] # Sequence of ints.
|
||||
|
||||
# Tuples.
|
||||
echo ('a', 1, true) # Tuple without explicit field names.
|
||||
echo (x: 1, y: 2) # Tuple with two int fields "x" and "y".
|
||||
Loading…
Add table
Add a link
Reference in a new issue