September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,2 @@
(defn lex? [a b]
(compare a b))

View file

@ -0,0 +1,28 @@
// version 1.0.6
operator fun <T> List<T>.compareTo(other: List<T>): Int
where T: Comparable<T>, T: Number {
for (i in 0 until this.size) {
if (other.size == i) return 1
when {
this[i] < other[i] -> return -1
this[i] > other[i] -> return 1
}
}
return if (this.size == other.size) 0 else -1
}
fun main(args: Array<String>) {
val lists = listOf(
listOf(1, 2, 3, 4, 5),
listOf(1, 2, 1, 5, 2, 2),
listOf(1, 2, 1, 5, 2),
listOf(1, 2, 1, 5, 2),
listOf(1, 2, 1, 3, 2),
listOf(1, 2, 0, 4, 4, 0, 0, 0),
listOf(1, 2, 0, 4, 4, 1, 0, 0)
)
for (i in 0 until lists.size) println("list${i + 1} : ${lists[i]}")
println()
for (i in 0 until lists.size - 1) println("list${i + 1} > list${i + 2} = ${lists[i] > lists[i + 1]}")
}

View file

@ -0,0 +1,5 @@
?{1,2,3}<{1,2,3,4} -- 1
?{1,2,3,4}<{1,2,3} -- 0
?{1,2,4}<{1,2,3} -- 0
?{1,2,3}<{1,2,3} -- 0
?{1,2,3}<{1,2,4} -- 1

View file

@ -0,0 +1,5 @@
fcn listLT(a,b){
a.walker().zip(b).filter1(fcn([(a,b)]){ a<b }) : // lazy
if(_) return(True);;
a.len()<b.len()
}