Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,2 @@
String myString = 'abcd';
System.debug('Size of String', myString.length());

View file

@ -0,0 +1,2 @@
"HELLO, WORLD"→Str1
Disp length(Str1)▶Dec,i

View file

@ -0,0 +1,23 @@
' FB 1.05.0 Win64
Dim s As String = "moose" '' variable length ascii string
Dim f As String * 5 = "moose" '' fixed length ascii string (in practice a zero byte is appended)
Dim z As ZString * 6 = "moose" '' fixed length zero terminated ascii string
Dim w As WString * 6 = "møøse" '' fixed length zero terminated unicode string
' Variable length strings have a descriptor consisting of 3 Integers (12 bytes on 32 bit, 24 bytes on 64 bit systems)
' In order, the descriptor contains the address of the data, the memory currently used and the memory allocated
' In Windows, WString uses UCS-2 encoding (i.e. 2 bytes per character, surrogates are not supported)
' In Linux, WString uses UCS-4 encoding (i.e. 4 bytes per character)
' The Len function always returns the length of the string in characters
' The SizeOf function returns the bytes used (by the descriptor in the case of variable length strings)
Print "s : " ; s, "Character Length : "; Len(s), "Byte Length : "; Len(s); " (data)"
Print "s : " ; s, "Character Length : "; Len(s), "Byte Length : "; SizeOf(s); " (descriptor)"
Print "f : " ; f, "Character Length : "; Len(s), "Byte Length : "; SizeOf(f)
Print "z : " ; z, "Character Length : "; Len(s), "Byte Length : "; SizeOf(z)
Print "w : " ; w, "Character Length : "; Len(s), "Byte Length : "; SizeOf(w)
Print
Sleep

View file

@ -0,0 +1,8 @@
(length "ASCII text")
10
(length "𝔘𝔫𝔦𝔠𝔬𝔡𝔢 𝔗𝔢𝒙𝔱")
12
> (set encoded (binary ("𝔘𝔫𝔦𝔠𝔬𝔡𝔢 𝔗𝔢𝒙𝔱" utf8)))
#B(240 157 148 152 240 157 148 171 240 157 ...)
> (length (unicode:characters_to_list encoded 'utf8))
12

View file

@ -0,0 +1,12 @@
> (set encoded (binary ("𝔘𝔫𝔦𝔠𝔬𝔡𝔢 𝔗𝔢𝒙𝔱" utf8)))
#B(240 157 148 152 240 157 148 171 240 157 ...)
> (byte_size encoded)
45
> (set bytes (binary ("𝔘𝔫𝔦𝔠𝔬𝔡𝔢 𝔗𝔢𝒙𝔱")))
#B(24 43 38 32 44 33 34 32 23 34 153 49)
> (byte_size bytes)
12
> (set encoded (binary ("ASCII text" utf8)))
#B(65 83 67 73 73 32 116 101 120 116)
> (byte_size encoded)
10

View file

@ -0,0 +1,3 @@
'Hello, world!'->size // 13
'møøse'->size // 5
'𝔘𝔫𝔦𝔠𝔬𝔡𝔢'->size // 7

View file

@ -0,0 +1,3 @@
'Hello, world!'->asBytes->size // 13
'møøse'->asBytes->size // 7
'𝔘𝔫𝔦𝔠𝔬𝔡𝔢'->asBytes->size // 28

View file

@ -0,0 +1,3 @@
utf8Str = "Hello world äöü"
put utf8Str.length
-- 15

View file

@ -0,0 +1,3 @@
utf8Str = "Hello world äöü"
put bytearray(utf8Str).length
-- 18

View file

@ -0,0 +1,4 @@
var s: string = "Hello, world! ☺"
echo '"',s, '"'," has byte length: ", len(s)
# -> "Hello, world! ☺" has unicode char length: 17

View file

@ -0,0 +1,6 @@
import unicode
var s: string = "Hello, world! ☺"
echo '"',s, '"'," has unicode char length: ", runeLen(s)
# -> "Hello, world! ☺" has unicode char length: 15

View file

@ -0,0 +1,2 @@
constant s = "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
?length(s)

View file

@ -0,0 +1,3 @@
"møøse" length print
"𝔘𝔫𝔦𝔠𝔬𝔡𝔢" length print
"J̲o̲s̲é̲" length print

View file

@ -0,0 +1,3 @@
aString = "Welcome to the Ring Programming Language"
aStringSize = len(aString)
see "Character lenghts : " + aStringSize

View file

@ -0,0 +1 @@
var str = "J\x{332}o\x{332}s\x{332}e\x{301}\x{332}";

View file

@ -0,0 +1 @@
say str.bytes.len; #=> 14

View file

@ -0,0 +1 @@
say str.encode('UTF-16').bytes.len; #=> 20

View file

@ -0,0 +1 @@
say str.chars.len; #=> 9

View file

@ -0,0 +1 @@
say str.graphs.len; #=> 4

View file

@ -0,0 +1,2 @@
spn:1> sizeof "Hello, wørld!"
= 14

View file

@ -0,0 +1 @@
let numberOfCharacters = "møøse".characters.count // 5

View file

@ -0,0 +1 @@
let numberOfBytesUTF16 = "møøse".utf16.count * 2 // 10

View file

@ -0,0 +1 @@
let numberOfBytesUTF16 = count("møøse".utf16) * 2 // 10

View file

@ -0,0 +1 @@
let numberOfBytesUTF16 = countElements("møøse".utf16) * 2 // 10

View file

@ -0,0 +1 @@
let numberOfCharacters = count("møøse") // 5

View file

@ -0,0 +1 @@
let numberOfCharacters = countElements("møøse") // 5

View file

@ -0,0 +1 @@
let numberOfCodePoints = "møøse".unicodeScalars.count // 5

View file

@ -0,0 +1 @@
let numberOfCodePoints = count("møøse".unicodeScalars) // 5

View file

@ -0,0 +1 @@
let numberOfCodePoints = countElements("møøse".unicodeScalars) // 5

View file

@ -0,0 +1 @@
let numberOfBytesUTF8 = "møøse".utf8.count // 7

View file

@ -0,0 +1 @@
let numberOfBytesUTF8 = count("møøse".utf8) // 7

View file

@ -0,0 +1 @@
let numberOfBytesUTF8 = countElements("møøse".utf8) // 7

View file

@ -0,0 +1,3 @@
System.print("møøse".bytes.count)
System.print("𝔘𝔫𝔦𝔠𝔬𝔡𝔢".bytes.count)
System.print("J̲o̲s̲é̲".bytes.count)

View file

@ -0,0 +1,3 @@
System.print("møøse".count)
System.print("𝔘𝔫𝔦𝔠𝔬𝔡𝔢".count)
System.print("J̲o̲s̲é̲".count)

View file

@ -0,0 +1,5 @@
$ cat String_length.jq
def describe:
"length of \(.) is \(length)";
("J̲o̲s̲é̲", "𝔘𝔫𝔦𝔠𝔬𝔡𝔢") | describe

View file

@ -0,0 +1,3 @@
$ jq -n -f String_length.jq
"length of J̲o̲s̲é̲ is 8"
"length of 𝔘𝔫𝔦𝔠𝔬𝔡𝔢 is 7"