Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
2
Task/Quoting-constructs/00-META.yaml
Normal file
2
Task/Quoting-constructs/00-META.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
from: http://rosettacode.org/wiki/Quoting_constructs
|
||||
7
Task/Quoting-constructs/00-TASK.txt
Normal file
7
Task/Quoting-constructs/00-TASK.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Pretty much every programming language has some form of quoting construct to allow embedding of data in a program, be it literal strings, numeric data or some combination thereof.
|
||||
|
||||
Show examples of the quoting constructs in your language. Explain where they would likely be used, what their primary use is, what limitations they have and why one might be preferred over another. Is one style [https://www.dictionary.com/browse/interpolate interpolating] and another not? Are there restrictions on the size of the quoted data? The type? The format?
|
||||
|
||||
This is intended to be open-ended and free form. If you find yourself writing more than a few thousand words of explanation, summarize and provide links to relevant documentation; but do provide at least a fairly comprehensive summary here, on this page, '''NOT''' just a link to [See the language docs].
|
||||
|
||||
Note: This is primarily for quoting constructs for data to be "embedded" in some way into a program. If there is some special format for external data, it may be mentioned but that isn't the focus of this task.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
LookUpTable: db $00,$03,$06,$09,$12 ;a sequence of pre-defined bytes
|
||||
|
||||
MyString: db "Hello World!",0 ;a null-terminated string
|
||||
|
||||
GraphicsData: incbin "C:\game\gfx\tilemap.chr" ;a file containing the game's graphics
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
dw $ABCD
|
||||
db $CD,$AB
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
lookup_table_lo:
|
||||
byte <Table00,<Table01,<Table02
|
||||
lookup_table_hi:
|
||||
byte >Table00,>Table01,>Table02
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
ByteData:
|
||||
DC.B $01,$02,$03,$04,$05
|
||||
even
|
||||
WordData:
|
||||
DC.W $01,$02
|
||||
DC.W $03,$04
|
||||
;the above was the same as DC.W $0001,$0002,$0003,$0004
|
||||
LongData:
|
||||
DC.L $00000001,$00000002,$00000004,$00000008
|
||||
|
||||
MyString:
|
||||
DC.B "Hello World!",0 ;a null terminator will not be automatically placed.
|
||||
even
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
DS.B 8 ;8 bytes, each equals 0
|
||||
DS.W 16 ;16 words, each equals zero
|
||||
DS.L 20 ;20 longs, each equals zero
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
ScreenSize equ $1200
|
||||
|
||||
MOVE.W (MyData),D0
|
||||
|
||||
MyData
|
||||
DC.W ScreenSize
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Printstring:
|
||||
;insert your code here
|
||||
|
||||
FunctionTable:
|
||||
DC.L PrintString ;represents the address of the function "PrintString"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
DC.B $0200>>3 ;evaluates to $0040. As long as the final result fits within the designated storage size, you're good.
|
||||
DC.W 4+5 ;evaluates to $0009
|
||||
DC.W (40*30)-1 ;evaluates to $1199
|
||||
DC.L MyFunction+4 ;evaluates to the address of MyFunction, plus 4.
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
TilemapCollision:
|
||||
DC.B $11,$11,$11,$11,$11,$11,$11,$11,$11,$11
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $11,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $10,$00,$00,$00,$00,$00,$00,$00,$00,$01
|
||||
DC.B $11,$11,$11,$11,$11,$11,$11,$11,$11,$11
|
||||
TilemapCollisionEnd:
|
||||
|
||||
MOVE.W #(TilemapCollisionEnd-TilemapCollision)-1,D0
|
||||
;gets the length of this region of memory, minus 1, into D0.
|
||||
; Again, even though the "operands" of this expression are longs,
|
||||
; their difference fits in 16 bits and that's all that matters.
|
||||
|
|
@ -0,0 +1 @@
|
|||
? 0 : ? -326.12E-5 : ? HELLO : ? "HELLO" : ? "HELLO
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
10 DATA 0,-326.12E-5,HELLO,"HELLO","HELLO
|
||||
20 READ A%: PRINT A%: READ A: PRINT A: READ A$: PRINT A$: READ A$: PRINT A$: READ A$: PRINT A$
|
||||
30 DATA AB"C
|
||||
40 READ A$: PRINT A$
|
||||
3
Task/Quoting-constructs/BQN/quoting-constructs-1.bqn
Normal file
3
Task/Quoting-constructs/BQN/quoting-constructs-1.bqn
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
'a'
|
||||
'b'
|
||||
@
|
||||
6
Task/Quoting-constructs/BQN/quoting-constructs-2.bqn
Normal file
6
Task/Quoting-constructs/BQN/quoting-constructs-2.bqn
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
123
|
||||
1.23
|
||||
123E5
|
||||
¯1234
|
||||
∞
|
||||
π
|
||||
1
Task/Quoting-constructs/BQN/quoting-constructs-3.bqn
Normal file
1
Task/Quoting-constructs/BQN/quoting-constructs-3.bqn
Normal file
|
|
@ -0,0 +1 @@
|
|||
⟨1, 2, 3⟩
|
||||
1
Task/Quoting-constructs/BQN/quoting-constructs-4.bqn
Normal file
1
Task/Quoting-constructs/BQN/quoting-constructs-4.bqn
Normal file
|
|
@ -0,0 +1 @@
|
|||
1‿2‿3
|
||||
2
Task/Quoting-constructs/BQN/quoting-constructs-5.bqn
Normal file
2
Task/Quoting-constructs/BQN/quoting-constructs-5.bqn
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"Hello World"
|
||||
"Quoted "" String"
|
||||
34
Task/Quoting-constructs/Ecstasy/quoting-constructs.ecstasy
Normal file
34
Task/Quoting-constructs/Ecstasy/quoting-constructs.ecstasy
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
module test {
|
||||
@Inject Console console;
|
||||
void run() {
|
||||
// characters are single quoted
|
||||
Char ch = 'x';
|
||||
console.print( $"ch={ch.quoted()}");
|
||||
|
||||
// strings are double quoted
|
||||
String greeting = "Hello";
|
||||
console.print( $"greeting={greeting.quoted()}");
|
||||
|
||||
// multi-line strings use '|' as a left column
|
||||
// the start of the first line escapes the '|' to indicate the start of the multiline
|
||||
// a trailing escape indicates that the current line continues without a linefeed
|
||||
String lines = \|first line
|
||||
|second line\
|
||||
| continued
|
||||
;
|
||||
console.print($|lines=
|
||||
|{lines}
|
||||
);
|
||||
|
||||
// the $"..." is a template string, containing {expressions}
|
||||
// the multi-line form of the template string uses $|
|
||||
String name = "Bob";
|
||||
String msg = $|{greeting} {name},
|
||||
|Have a nice day!
|
||||
|{ch}{ch}{ch}
|
||||
;
|
||||
console.print($|msg=
|
||||
|{msg}
|
||||
);
|
||||
}
|
||||
}
|
||||
31
Task/Quoting-constructs/FreeBASIC/quoting-constructs.basic
Normal file
31
Task/Quoting-constructs/FreeBASIC/quoting-constructs.basic
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
'In FB there is no substr function, then
|
||||
'Function taken fron the https://www.freebasic.net/forum/index.php
|
||||
|
||||
Function substr(Byref soriginal As String, Byref spattern As Const String, Byref sreplacement As Const String) As String
|
||||
' in <soriginal> replace all occurrences of <spattern> by <sreplacement>
|
||||
Dim As Uinteger p, q
|
||||
|
||||
If sreplacement <> spattern Then
|
||||
p = Instr(soriginal, spattern)
|
||||
If p Then
|
||||
q = Len(sreplacement)
|
||||
If q = 0 Then q = 1
|
||||
Do
|
||||
soriginal = Left(soriginal, p - 1) + sreplacement + Mid(soriginal, p + Len(spattern))
|
||||
p = Instr(p + q, soriginal, spattern)
|
||||
Loop Until p = 0
|
||||
End If
|
||||
End If
|
||||
Return soriginal
|
||||
End Function
|
||||
|
||||
Dim As String text(1 To 3)
|
||||
text(1) = "This is 'first' example for quoting"
|
||||
text(2) = "This is second 'example' for quoting"
|
||||
text(3) = "This is third example 'for' quoting"
|
||||
|
||||
For n As Integer = 1 To Ubound(text)
|
||||
Print !"text for quoting:\n"; text(n)
|
||||
Print !"quoted text:\n"; substr(text(n),"'",""); !"\n"
|
||||
Next n
|
||||
Sleep
|
||||
78
Task/Quoting-constructs/Go/quoting-constructs.go
Normal file
78
Task/Quoting-constructs/Go/quoting-constructs.go
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
/* Quoting constructs in Go. */
|
||||
|
||||
// In Go a Unicode codepoint, expressed as a 32-bit integer, is referred to as a 'rune'
|
||||
// but the more familiar term 'character' will be used instead here.
|
||||
|
||||
// Character literal (single quotes).
|
||||
// Can contain any single character including an escaped character.
|
||||
var (
|
||||
rl1 = 'a'
|
||||
rl2 = '\'' // single quote can only be included in escaped form
|
||||
)
|
||||
|
||||
// Interpreted string literal (double quotes).
|
||||
// A sequence of characters including escaped characters.
|
||||
var (
|
||||
is1 = "abc"
|
||||
is2 = "\"ab\tc\"" // double quote can only be included in escaped form
|
||||
)
|
||||
|
||||
// Raw string literal(single back quotes).
|
||||
// Can contain any character including a 'physical' new line but excluding back quote.
|
||||
// Escaped characters are interpreted literally i.e. `\n` is backslash followed by n.
|
||||
// Raw strings are typically used for hard-coding pieces of text perhaps
|
||||
// including single and/or double quotes without the need to escape them.
|
||||
// They are particularly useful for regular expressions.
|
||||
var (
|
||||
rs1 = `
|
||||
first"
|
||||
second'
|
||||
third"
|
||||
`
|
||||
rs2 = `This is one way of including a ` + "`" + ` in a raw string literal.`
|
||||
rs3 = `\d+` // a sequence of one or more digits in a regular expression
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(rl1, rl2) // prints the code point value not the character itself
|
||||
fmt.Println(is1, is2)
|
||||
fmt.Println(rs1)
|
||||
fmt.Println(rs2)
|
||||
re := regexp.MustCompile(rs3)
|
||||
fmt.Println(re.FindString("abcd1234efgh"))
|
||||
|
||||
/* None of the above quoting constructs can deal directly with interpolation.
|
||||
This is done instead using library functions.
|
||||
*/
|
||||
|
||||
// C-style using %d, %f, %s etc. within a 'printf' type function.
|
||||
n := 3
|
||||
fmt.Printf("\nThere are %d quoting constructs in Go.\n", n)
|
||||
|
||||
// Using a function such as fmt.Println which can take a variable
|
||||
// number of arguments, of any type, and print then out separated by spaces.
|
||||
s := "constructs"
|
||||
fmt.Println("There are", n, "quoting", s, "in Go.")
|
||||
|
||||
// Using the function os.Expand which requires a mapper function to fill placeholders
|
||||
// denoted by ${...} within a string.
|
||||
mapper := func(placeholder string) string {
|
||||
switch placeholder {
|
||||
case "NUMBER":
|
||||
return strconv.Itoa(n)
|
||||
case "TYPES":
|
||||
return s
|
||||
}
|
||||
return ""
|
||||
}
|
||||
fmt.Println(os.Expand("There are ${NUMBER} quoting ${TYPES} in Go.", mapper))
|
||||
}
|
||||
4
Task/Quoting-constructs/J/quoting-constructs-1.j
Normal file
4
Task/Quoting-constructs/J/quoting-constructs-1.j
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
0 :0
|
||||
1 2 3
|
||||
4 5 6
|
||||
)
|
||||
4
Task/Quoting-constructs/J/quoting-constructs-2.j
Normal file
4
Task/Quoting-constructs/J/quoting-constructs-2.j
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{{)n
|
||||
1 2 3
|
||||
4 5 6
|
||||
}}
|
||||
12
Task/Quoting-constructs/J/quoting-constructs-3.j
Normal file
12
Task/Quoting-constructs/J/quoting-constructs-3.j
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
NB. no trailing linefeed
|
||||
A=: '1 2 3'
|
||||
|
||||
NB. removing linefeed
|
||||
A=: 0 : 0-.LF
|
||||
1 2 3
|
||||
)
|
||||
|
||||
NB. removing linefeed
|
||||
A=: {{)n
|
||||
1 2 3
|
||||
}}-.LF
|
||||
7
Task/Quoting-constructs/J/quoting-constructs-4.j
Normal file
7
Task/Quoting-constructs/J/quoting-constructs-4.j
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{{
|
||||
{{
|
||||
A=: {{)n
|
||||
1 2 3
|
||||
}}-.LF
|
||||
}}''
|
||||
}}''
|
||||
3
Task/Quoting-constructs/Jq/quoting-constructs-1.jq
Normal file
3
Task/Quoting-constructs/Jq/quoting-constructs-1.jq
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def data:
|
||||
"A string", 1, {"a":0}, [1,2,[3]]
|
||||
;
|
||||
2
Task/Quoting-constructs/Jq/quoting-constructs-2.jq
Normal file
2
Task/Quoting-constructs/Jq/quoting-constructs-2.jq
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"This is not such a "
|
||||
+ "long string after all."
|
||||
6
Task/Quoting-constructs/Julia/quoting-constructs-1.julia
Normal file
6
Task/Quoting-constructs/Julia/quoting-constructs-1.julia
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
julia> str = "Hello, world.\n"
|
||||
"Hello, world.\n"
|
||||
|
||||
julia> """Contains "quote" characters and
|
||||
a newline"""
|
||||
"Contains \"quote\" characters and \na newline"
|
||||
5
Task/Quoting-constructs/Julia/quoting-constructs-2.julia
Normal file
5
Task/Quoting-constructs/Julia/quoting-constructs-2.julia
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
julia> str = """
|
||||
Hello,
|
||||
world.
|
||||
"""
|
||||
" Hello,\n world.\n"
|
||||
2
Task/Quoting-constructs/Julia/quoting-constructs-3.julia
Normal file
2
Task/Quoting-constructs/Julia/quoting-constructs-3.julia
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
julia> "$greet, $whom.\n"
|
||||
"Hello, world.\n"
|
||||
2
Task/Quoting-constructs/Julia/quoting-constructs-4.julia
Normal file
2
Task/Quoting-constructs/Julia/quoting-constructs-4.julia
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
julia> "1 + 2 = $(1 + 2)"
|
||||
"1 + 2 = 3"
|
||||
2
Task/Quoting-constructs/Julia/quoting-constructs-5.julia
Normal file
2
Task/Quoting-constructs/Julia/quoting-constructs-5.julia
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
julia> 'π'
|
||||
'π': Unicode U+03C0 (category Ll: Letter, lowercase)
|
||||
8
Task/Quoting-constructs/Julia/quoting-constructs-6.julia
Normal file
8
Task/Quoting-constructs/Julia/quoting-constructs-6.julia
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
julia> mycommand = `echo hello`
|
||||
`echo hello`
|
||||
|
||||
julia> typeof(mycommand)
|
||||
Cmd
|
||||
|
||||
julia> run(mycommand);
|
||||
hello
|
||||
23
Task/Quoting-constructs/Julia/quoting-constructs-7.julia
Normal file
23
Task/Quoting-constructs/Julia/quoting-constructs-7.julia
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
julia> a = :+
|
||||
:+
|
||||
|
||||
julia> typeof(a)
|
||||
Symbol
|
||||
|
||||
julia> b = quote + end
|
||||
quote
|
||||
#= REPL[3]:1 =#
|
||||
+
|
||||
end
|
||||
|
||||
julia> typeof(b)
|
||||
Expr
|
||||
|
||||
julia> eval(a) == eval(b)
|
||||
true
|
||||
|
||||
julia> c = :(2 + 3)
|
||||
:(2 + 3)
|
||||
|
||||
julia> eval(c)
|
||||
5
|
||||
22
Task/Quoting-constructs/Lua/quoting-constructs.lua
Normal file
22
Task/Quoting-constructs/Lua/quoting-constructs.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
s1 = "This is a double-quoted 'string' with embedded single-quotes."
|
||||
s2 = 'This is a single-quoted "string" with embedded double-quotes.'
|
||||
s3 = "this is a double-quoted \"string\" with escaped double-quotes."
|
||||
s4 = 'this is a single-quoted \'string\' with escaped single-quotes.'
|
||||
s5 = [[This is a long-bracket "'string'" with embedded single- and double-quotes.]]
|
||||
s6 = [=[This is a level 1 long-bracket ]]string[[ with [[embedded]] long-brackets.]=]
|
||||
s7 = [==[This is a level 2 long-bracket ]=]string[=[ with [=[embedded]=] level 1 long-brackets, etc.]==]
|
||||
s8 = [[This is
|
||||
a long-bracket string
|
||||
with embedded
|
||||
line feeds]]
|
||||
s9 = "any \0 form \1 of \2 string \3 may \4 contain \5 raw \6 binary \7 data \xDB"
|
||||
print(s1)
|
||||
print(s2)
|
||||
print(s3)
|
||||
print(s4)
|
||||
print(s5)
|
||||
print(s6)
|
||||
print(s7)
|
||||
print(s8)
|
||||
print(s9) -- with audible "bell" from \7 if supported by os
|
||||
print("some raw binary:", #s9, s9:byte(5), s9:byte(12), s9:byte(17))
|
||||
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".
|
||||
46
Task/Quoting-constructs/Perl/quoting-constructs.pl
Normal file
46
Task/Quoting-constructs/Perl/quoting-constructs.pl
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# 20221202 Perl programming solution
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
print <<`EXEC` # superfluous alternative to qx/ / and ` `
|
||||
sleep 2; ls /etc/resolv.conf
|
||||
EXEC
|
||||
;
|
||||
# only with quoted begin tag then you can have spaces in between
|
||||
print <<END # so << 'END' or << "END" and semi-colon is always optional
|
||||
Make sure that the end tag must be exactly the same as the begin tag.
|
||||
END
|
||||
; # the above wouldn't have worked had it been something like
|
||||
# END␣ ␣ ␣ (with redundant trailing spaces)
|
||||
|
||||
print <<"HERE1", <<"HERE2" # it is also possible to stack heredocs
|
||||
Hello from HERE1
|
||||
HERE1
|
||||
Hello from HERE2
|
||||
HERE2
|
||||
;
|
||||
|
||||
my $haystack = 'Santa says HoHoHo'; # a quoted pattern expanded before
|
||||
my $needle = "\x48\x6F"; # the regex is interpreted
|
||||
print "1) Found.\n" if $haystack =~ /$needle{3}/; # Matches Hooo
|
||||
print "2) Found.\n" if $haystack =~ /($needle){3}/; # Do what you mean
|
||||
|
||||
# due to autoconversion, things may still work the same
|
||||
{ use Benchmark; # under (usually overlooked) scalar interpolation
|
||||
my ( $iterations, $x, $y ) = 1e7, rand, rand;
|
||||
timethese( $iterations, { 'normal' => ' $x + $y',
|
||||
'useless' => '"$x" + "$y"' } );
|
||||
} # however in the 2nd case the boxing and unboxing are unnecessary
|
||||
|
||||
{ # the following illustrate some behaviors under array interpolation
|
||||
my @Y_M_D = sub{$_[5]+1900,$_[4]+1,$_[3]}->(localtime(time));
|
||||
local $\ = "\n";
|
||||
print @Y_M_D; # YMD
|
||||
print "@Y_M_D"; # Y M D
|
||||
local $, = '-'; # output field separator
|
||||
print @Y_M_D; # Y-M-D
|
||||
print "@Y_M_D"; # Y M D
|
||||
local $" = '_'; # interpolated list separator
|
||||
print "@Y_M_D"; # Y_M_D
|
||||
}
|
||||
7
Task/Quoting-constructs/Phix/quoting-constructs-1.phix
Normal file
7
Task/Quoting-constructs/Phix/quoting-constructs-1.phix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-->
|
||||
<span style="color: #008080;">constant</span> <span style="color: #000000;">t123</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">`
|
||||
one
|
||||
two
|
||||
three
|
||||
`</span>
|
||||
<!--
|
||||
7
Task/Quoting-constructs/Phix/quoting-constructs-2.phix
Normal file
7
Task/Quoting-constructs/Phix/quoting-constructs-2.phix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-->
|
||||
<span style="color: #008080;">constant</span> <span style="color: #000000;">t123</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"""
|
||||
one
|
||||
two
|
||||
three
|
||||
"""</span>
|
||||
<!--
|
||||
5
Task/Quoting-constructs/Phix/quoting-constructs-3.phix
Normal file
5
Task/Quoting-constructs/Phix/quoting-constructs-3.phix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-->
|
||||
<span style="color: #000000;">x</span><span style="color: #008000;">"1 2 34 5678_AbC"</span> <span style="color: #000080;font-style:italic;">-- same as {0x01, 0x02, 0x34, 0x56, 0x78, 0xAB, 0x0C}
|
||||
-- note however it displays as {1,2,52,86,120,171,12}
|
||||
-- whereas x"414243" displays as "ABC" (as all chars)</span>
|
||||
<!--
|
||||
4
Task/Quoting-constructs/Phix/quoting-constructs-4.phix
Normal file
4
Task/Quoting-constructs/Phix/quoting-constructs-4.phix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{2, 3, 5, 7, 11, 13, 17, 19}
|
||||
{1, 2, {3, 3, 3}, 4, {5, {6}}}
|
||||
{{"John", "Smith"}, 52389, 97.25}
|
||||
{} -- the 0-element sequence
|
||||
61
Task/Quoting-constructs/REXX/quoting-constructs.rexx
Normal file
61
Task/Quoting-constructs/REXX/quoting-constructs.rexx
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*REXX program demonstrates various ways to express a string of characters or numbers.*/
|
||||
a= 'This is one method of including a '' (an apostrophe) within a string.'
|
||||
b= "This is one method of including a ' (an apostrophe) within a string."
|
||||
|
||||
/*sometimes, an apostrophe is called */
|
||||
/*a quote. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
c= "This is one method of including a "" (a double quote) within a string."
|
||||
d= 'This is one method of including a " (a double quote) within a string.'
|
||||
|
||||
/*sometimes, a double quote is also */
|
||||
/*called a quote, which can make for */
|
||||
/*some confusion and bewilderment. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
f= 'This is one method of expressing a long literal by concatenations, the ' || ,
|
||||
'trailing character of the above clause must contain a trailing ' || ,
|
||||
'comma (,) === note the embedded trailing blank in the above 2 statements.'
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
g= 'This is another method of expressing a long literal by ' ,
|
||||
"abutments, the trailing character of the above clause must " ,
|
||||
'contain a trailing comma (,)'
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
h= 'This is another method of expressing a long literal by ' , /*still continued.*/
|
||||
"abutments, the trailing character of the above clause must " ,
|
||||
'contain a trailing comma (,) --- in this case, the comment /* ... */ is ' ,
|
||||
'essentially is not considered to be "part of" the REXX clause.'
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
i= 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109
|
||||
|
||||
/*This is one way to express a list of */
|
||||
/*numbers that don't have a sign. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
j= 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109,
|
||||
71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181
|
||||
|
||||
/*This is one way to express a long */
|
||||
/*list of numbers that don't have a */
|
||||
/*sign. */
|
||||
/*Note that this form of continuation */
|
||||
/*implies a blank is abutted to first */
|
||||
/*part of the REXX statement. */
|
||||
/*Also note that some REXXs have a */
|
||||
/*maximum clause length. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
k= 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109,
|
||||
71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181
|
||||
|
||||
/*The J and K values are identical,*/
|
||||
/*superfluous and extraneous blanks are*/
|
||||
/*ignored. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
l= '-2 3 +5 7 -11 13 17 19 -23 29 -31 37 -41 43 47 -53 59 -61 67 -71 73 79 -83 89 97 -101'
|
||||
|
||||
/*This is one way to express a list of */
|
||||
/*numbers that have a sign. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
m= a b c d f g h i j k l /*this will create a list of all the */
|
||||
/*listed strings used (so far) into */
|
||||
/*the variable L (with an */
|
||||
/*intervening blank between each */
|
||||
/*variable's value. */
|
||||
11
Task/Quoting-constructs/Ring/quoting-constructs.ring
Normal file
11
Task/Quoting-constructs/Ring/quoting-constructs.ring
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
text = list(3)
|
||||
|
||||
text[1] = "This is 'first' example for quoting"
|
||||
text[2] = "This is second 'example' for quoting"
|
||||
text[3] = "This is third example 'for' quoting"
|
||||
|
||||
for n = 1 to len(text)
|
||||
see "text for quoting: " + nl + text[n] + nl
|
||||
str = substr(text[n],"'","")
|
||||
see "quoted text:" + nl + str + nl + nl
|
||||
next
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
$a
|
||||
$Å
|
||||
$日
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
aBlock value. "evaluate the block, passing no argument"
|
||||
anotherBlock value:1 value:2. "evaluate the block, passing two arguments"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
in the True class:
|
||||
ifTrue: aBlock
|
||||
^ aBlock value "I am true, so I evaluate the block"
|
||||
|
||||
in the False class:
|
||||
ifTrue: aBlock
|
||||
^ nil "I am false, so I ignore the block"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#{
|
||||
foo: <someConstant>
|
||||
bar: <someConstant>
|
||||
}
|
||||
11
Task/Quoting-constructs/Smalltalk/quoting-constructs-13.st
Normal file
11
Task/Quoting-constructs/Smalltalk/quoting-constructs-13.st
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#u16( 1 2 3 ). " an array of unsigned int16s "
|
||||
#u32( 1 2 3 ). " an array of unsigned int32s "
|
||||
#u64( 1 2 3 ). " an array of unsigned int64s "
|
||||
#s16( -1 2 3 ). " an array of signed int16s "
|
||||
#s32( -1 2 3 ). " an array of signed int32s "
|
||||
#s64( -1 2 3 ). " an array of signed int64s "
|
||||
#f16( -1 2.0 3 ). " an array of float16s "
|
||||
#f32( -1 2.0 3 ). " an array of float32s "
|
||||
#f64( -1 2.0 3 ). " an array of float64s "
|
||||
#b( 1 0 1 1 0 0 ). " an array of bits "
|
||||
#B( true false true true ). " an array of booleans "
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
'hello'
|
||||
'日本語
|
||||
|
|
@ -0,0 +1 @@
|
|||
c'hello\nthis\tis a C string\0x0D'
|
||||
|
|
@ -0,0 +1 @@
|
|||
e'hello world; it is now {Time now}\n'
|
||||
|
|
@ -0,0 +1 @@
|
|||
#( 1 1.234 (1/2) foo 'hello' #(9 8 7) (99 88 77) $λ '日本語' true [1 2 3] false)
|
||||
|
|
@ -0,0 +1 @@
|
|||
#[ 1 2 16rFF 2r0101010 ]
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#'foo'
|
||||
#'foo bar baz'
|
||||
#foo. " same as #'foo' "
|
||||
#'++'
|
||||
#++ " same as #'++' "
|
||||
#a:b:c: " same as #'a:b:c:' "
|
||||
|
|
@ -0,0 +1 @@
|
|||
[ expression . expression ... expression ]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[:arg1 :arg2 :... :argN | expression . expression ... expression ]
|
||||
29
Task/Quoting-constructs/Wren/quoting-constructs.wren
Normal file
29
Task/Quoting-constructs/Wren/quoting-constructs.wren
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import "/fmt" for Fmt
|
||||
|
||||
// simple string literal
|
||||
System.print("Hello world!")
|
||||
|
||||
// string literal including an escape sequence
|
||||
System.print("Hello tabbed\tworld!")
|
||||
|
||||
// interpolated string literal
|
||||
var w = "world"
|
||||
System.print("Hello interpolated %(w)!")
|
||||
|
||||
// 'printf' style
|
||||
Fmt.print("Hello 'printf' style $s!", w)
|
||||
|
||||
// more complicated interpolated string literal
|
||||
var h = "Hello"
|
||||
System.print("%(Fmt.s(-8, h)) more complicated interpolated %(w.map { |c| "%(c + "\%")" }.join())!")
|
||||
|
||||
// more complicated 'printf' style
|
||||
Fmt.print("$-8s more complicated 'printf' style $s\%!", h, w.join("\%"))
|
||||
|
||||
// raw string literal
|
||||
var r = """
|
||||
Hello, raw string literal which interpets a control code such as "\n" and an
|
||||
interpolation such as %(h) as verbatim text.
|
||||
Single (") or dual ("") double-quotes can be included without problem.
|
||||
"""
|
||||
System.print(r)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
MyString:
|
||||
byte "Hello World",0 ;a null-terminated string
|
||||
LookupTable:
|
||||
byte &03,&06,&09,&0C ;a pre-defined sequence of bytes (similar in concept to enum in C)
|
||||
TileGfx:
|
||||
incbin "Z:\game\gfx\tilemap.bmp" ;a file containing bitmap graphics data
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
word $ABCD
|
||||
word $CD,$AB
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
lookup_table_lo:
|
||||
byte <Table00,<Table01,<Table02
|
||||
lookup_table_hi:
|
||||
byte >Table00,>Table01,>Table02
|
||||
6
Task/Quoting-constructs/Zkl/quoting-constructs.zkl
Normal file
6
Task/Quoting-constructs/Zkl/quoting-constructs.zkl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#<<<
|
||||
text:=
|
||||
"
|
||||
A
|
||||
";
|
||||
#<<<
|
||||
Loading…
Add table
Add a link
Reference in a new issue