CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
2
Task/Binary-strings/Common-Lisp/binary-strings-1.lisp
Normal file
2
Task/Binary-strings/Common-Lisp/binary-strings-1.lisp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"string"
|
||||
(coerce (#\s #\t #\r #\i #\n #\g) 'string)
|
||||
1
Task/Binary-strings/Common-Lisp/binary-strings-2.lisp
Normal file
1
Task/Binary-strings/Common-Lisp/binary-strings-2.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defvar *string* "string")
|
||||
1
Task/Binary-strings/Common-Lisp/binary-strings-3.lisp
Normal file
1
Task/Binary-strings/Common-Lisp/binary-strings-3.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(equal "string" "string")
|
||||
1
Task/Binary-strings/Common-Lisp/binary-strings-4.lisp
Normal file
1
Task/Binary-strings/Common-Lisp/binary-strings-4.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(copy-seq "string")
|
||||
4
Task/Binary-strings/Common-Lisp/binary-strings-5.lisp
Normal file
4
Task/Binary-strings/Common-Lisp/binary-strings-5.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(defun string-empty-p (string)
|
||||
(cond
|
||||
((= 0 (length string))t)
|
||||
(nil)))
|
||||
1
Task/Binary-strings/Common-Lisp/binary-strings-6.lisp
Normal file
1
Task/Binary-strings/Common-Lisp/binary-strings-6.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(concatenate 'string "string" "b")
|
||||
2
Task/Binary-strings/Common-Lisp/binary-strings-7.lisp
Normal file
2
Task/Binary-strings/Common-Lisp/binary-strings-7.lisp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(subseq "string" 1 6)
|
||||
"ring"
|
||||
45
Task/Binary-strings/D/binary-strings.d
Normal file
45
Task/Binary-strings/D/binary-strings.d
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import std.array: empty;
|
||||
import std.string: replace;
|
||||
|
||||
void main() {
|
||||
// String creation (destruction is usually handled by
|
||||
// the garbage collector)
|
||||
ubyte[] str1;
|
||||
|
||||
// String assignments
|
||||
str1 = cast(ubyte[])"blah";
|
||||
// hex string, same as "\x00\xFB\xCD\x32\xFD\x0A"
|
||||
// whitespace and newlines are ignored
|
||||
str1 = cast(ubyte[])x"00 FBCD 32FD 0A";
|
||||
|
||||
// String comparison
|
||||
ubyte[] str2;
|
||||
if (str1 == str2) {} // strings equal
|
||||
|
||||
// String cloning and copying
|
||||
str2 = str1.dup; // copy entire string or array
|
||||
|
||||
// Check if a string is empty
|
||||
if (str1.empty) {} // string empty
|
||||
if (str1.length) {} // string not empty
|
||||
if (!str1.length) {} // string empty
|
||||
|
||||
// Append a ubyte to a string
|
||||
str1 ~= x"0A";
|
||||
str1 ~= 'a';
|
||||
|
||||
// Extract a substring from a string
|
||||
str1 = cast(ubyte[])"blork";
|
||||
// this takes off the first and last bytes and
|
||||
// assigns them to the new ubyte string
|
||||
// This is just a light slice, no string data copied
|
||||
ubyte[] substr = str1[1 .. $-1];
|
||||
|
||||
// Replace every occurrence of a ubyte (or a string)
|
||||
// in a string with another string
|
||||
str1 = cast(ubyte[])"blah";
|
||||
replace(cast(char[])str1, "la", "al");
|
||||
|
||||
// Join strings
|
||||
ubyte[] str3 = str1 ~ str2;
|
||||
}
|
||||
2
Task/Binary-strings/E/binary-strings-1.e
Normal file
2
Task/Binary-strings/E/binary-strings-1.e
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
? def int8 := <type:java.lang.Byte>
|
||||
# value: int8
|
||||
8
Task/Binary-strings/E/binary-strings-2.e
Normal file
8
Task/Binary-strings/E/binary-strings-2.e
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
? def bstr := [].diverge(int8)
|
||||
# value: [].diverge()
|
||||
|
||||
? def bstr1 := [1,2,3].diverge(int8)
|
||||
# value: [1, 2, 3].diverge()
|
||||
|
||||
? def bstr2 := [-0x7F,0x2,0x3].diverge(int8)
|
||||
# value: [-127, 2, 3].diverge()
|
||||
2
Task/Binary-strings/E/binary-strings-3.e
Normal file
2
Task/Binary-strings/E/binary-strings-3.e
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
? bstr1.snapshot() < bstr2.snapshot()
|
||||
# value: false
|
||||
5
Task/Binary-strings/E/binary-strings-4.e
Normal file
5
Task/Binary-strings/E/binary-strings-4.e
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
? bstr1.size().isZero()
|
||||
# value: false
|
||||
|
||||
? bstr.size().isZero()
|
||||
# value: true
|
||||
3
Task/Binary-strings/E/binary-strings-5.e
Normal file
3
Task/Binary-strings/E/binary-strings-5.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
? bstr.push(0)
|
||||
? bstr
|
||||
# value: [0].diverge()
|
||||
6
Task/Binary-strings/E/binary-strings-6.e
Normal file
6
Task/Binary-strings/E/binary-strings-6.e
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
? bstr1(1, 2)
|
||||
# value: [2]
|
||||
|
||||
? bstr.replace(0, bstr.size(), bstr2, 1, 3)
|
||||
? bstr
|
||||
# value: [2, 3].diverge()
|
||||
3
Task/Binary-strings/E/binary-strings-7.e
Normal file
3
Task/Binary-strings/E/binary-strings-7.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
? for i => byte ? (byte == 2) in bstr2 { bstr2[i] := -1 }
|
||||
? bstr2
|
||||
# value: [-127, -1, 3].diverge()
|
||||
3
Task/Binary-strings/E/binary-strings-8.e
Normal file
3
Task/Binary-strings/E/binary-strings-8.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
? bstr1.append(bstr2)
|
||||
? bstr1
|
||||
# value: [1, 2, 3, -127, 2, 3].diverge()
|
||||
Loading…
Add table
Add a link
Reference in a new issue