Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,19 @@
|
||||
public apply(action: handler(value: Int) (answer: Int), value: Int) (answer: Int) {
|
||||
answer = action(value)
|
||||
}
|
||||
|
||||
public mapValues(values: List<Int>) (answer: List<Int>) {
|
||||
answer = each(calc.value.adjust, values)
|
||||
}
|
||||
|
||||
public total(values: List<Int>) (answer: Int) {
|
||||
answer = reduce(add, values, 0)
|
||||
}
|
||||
|
||||
add(value: Int, state: Int) (answer: Int) {
|
||||
answer = state + calc.value.adjust(value)
|
||||
}
|
||||
|
||||
public verify() (answer: Bool) {
|
||||
answer = total([1, 2, 3]) == 9
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
public type Row {
|
||||
id: Id
|
||||
count: Int
|
||||
}
|
||||
|
||||
public type Problem {
|
||||
error Rejected(message: Text)
|
||||
}
|
||||
|
||||
public adjust(value: Int) (answer: Int) {
|
||||
answer = value + 1
|
||||
}
|
||||
|
||||
public make(value: Int) (row: Row) {
|
||||
row = Row { id = dever.id.fromText("雪")
|
||||
count = value }
|
||||
}
|
||||
|
||||
public positive(value: Int >= 0) (answer: Int) {
|
||||
answer = value
|
||||
}
|
||||
public positive(value: Int < 0) (answer: Int) {
|
||||
fail(Problem.Rejected("negative"))
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
verify() (answer: Bool) {
|
||||
row = calc.value.make(7)
|
||||
copy = row
|
||||
copy.count = 8
|
||||
answer = row.count == 7 and copy.count == 8 and row.id == dever.id.fromText("雪") and calc.batch.mapValues([1, 2, 3]) == [2, 3, 4] and calc.batch.total([1, 2, 3]) == 9 and calc.batch.apply(adjust, 2) == 4 and calc.batch.apply(calc.value.adjust, 2) == 3
|
||||
}
|
||||
|
||||
adjust(value: Int) (answer: Int) {
|
||||
answer = value * 2
|
||||
}
|
||||
|
||||
failureEntry() (answer: Int) {
|
||||
answer = calc.batch.apply(calc.value.positive, -1)
|
||||
}
|
||||
|
||||
dispatch(value: Int) (answer: Int) {
|
||||
answer = calc.batch.apply(adjust, value)
|
||||
}
|
||||
|
||||
dispatchTotal(values: List<Int>) (answer: Int) {
|
||||
answer = sum(dispatch, values)
|
||||
}
|
||||
|
||||
faultEntry() (answer: Int) {
|
||||
answer = calc.batch.apply(calc.value.adjust, 9223372036854775807)
|
||||
}
|
||||
Reference in new issue
Block a user