Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,11 @@
|
|||
local(
|
||||
first = array(1,2,1,3,2),
|
||||
second = array(1,2,0,4,4,0,0,0),
|
||||
)
|
||||
#first < #second
|
||||
|
||||
local(
|
||||
first = array(1,1,1,3,2),
|
||||
second = array(1,2,0,4,4,0,0,0),
|
||||
)
|
||||
#first < #second
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
proc `<`[T](a, b: openarray[T]): bool =
|
||||
for i in 0 .. min(a.len, b.len):
|
||||
if a[i] < b[i]: return true
|
||||
if a[i] > b[i]: return false
|
||||
return a.len < b.len
|
||||
|
||||
echo([1,2,1,3,2] < [1,2,0,4,4,0,0,0])
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
list1 = "1, 2, 1, 5, 2"
|
||||
list2 = "5, 2, 1, 5, 2, 2"
|
||||
list3 = "1, 2, 3, 4, 5"
|
||||
list4 = "1, 2, 3, 4, 5"
|
||||
|
||||
if order(list1, list2) = 0 see "list1=list2" + nl
|
||||
but order(list1, list2) < 0 see "list1<list2" + nl
|
||||
else see "list1>list2" + nl ok
|
||||
|
||||
if order(list2, list3) = 0 see "list2=list3" + nl
|
||||
but order(list2, list3) < 0 see "list2<list3" + nl
|
||||
else see "list2>list3" + nl ok
|
||||
|
||||
if order(list3, list4) = 0 see "list3=list4" + nl
|
||||
but order(list3, list4) < 0 see "list3<list4" + nl
|
||||
else see "list3>list4" + nl ok
|
||||
|
||||
func order alist, blist
|
||||
return strcmp(alist, blist)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
func ordered(a, b) {
|
||||
(a <=> b) < 0
|
||||
}
|
||||
|
||||
for p in [
|
||||
Pair([1,2,4], [1,2,4]),
|
||||
Pair([1,2,4], [1,2] ),
|
||||
Pair([1,2], [1,2,4]),
|
||||
] {
|
||||
var a = p.first
|
||||
var b = p.second
|
||||
var before = ordered(a, b)
|
||||
say "#{a} comes before #{b} : #{before}"
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
let a = [1,2,1,3,2]
|
||||
let b = [1,2,0,4,4,0,0,0]
|
||||
println(lexicographicalCompare(a, b)) // this is "less than"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
def (a < b) :case (or list?.a list?.b)
|
||||
if not.b
|
||||
nil
|
||||
not.a
|
||||
b
|
||||
(car.a = car.b)
|
||||
(cdr.a < cdr.b)
|
||||
:else
|
||||
(car.a < car.b)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
[1,2,3] < [1,2,3,4] # => true
|
||||
[1,2,3] < [1,2,4] # => true
|
||||
[1,2,3] < [1,2,3] # => false
|
||||
Loading…
Add table
Add a link
Reference in a new issue