Loops/Wrong ranges: Difference between revisions

Content added Content deleted
(PascalABC.NET)
 
Line 1,961: Line 1,961:


{{trans|Python}}
{{trans|Python}}
<syntaxhighlight lang="langur">val .data = qs:block END
<syntaxhighlight lang="langur">
val data = qs:block END
start stop increment comment
start stop increment comment
-2 2 1 Normal
-2 2 1 Normal
Line 1,974: Line 1,975:
END
END


# Process data string into table.
var .table = submatches(RE/([^ ]+) +([^ ]+) +([^ ]+) +(.+)\n?/, .data)
# We could have just started with a list of lists, of course.
var table = submatches(RE/([^ ]+) +([^ ]+) +([^ ]+) +(.+)\n?/, data)


for i in 2..len(table) {
val .f = fn .x: number .x
table[i] = map([number, number, number, _], table[i])
for .i in 2..len(.table) {
.table[.i] = map [.f, .f, .f, _], .table[.i]
}
}


for .test in rest(.table) {
for test in rest(table) {
val .start, .stop, .inc, .comment = .test
val start, stop, inc, comment = test
{
{
val .series = series(.start .. .stop, .inc)
val s = series(start .. stop, inc)
catch {
catch {
writeln "{{.comment}}\nERROR: {{_err["msg"]:L200(...)}}\n"
writeln "{{comment}}\nERROR: {{_err'msg:L200(...)}}\n"
} else {
} else {
writeln "{{.comment}}\nresult: {{.series}}\n"
writeln "{{comment}}\nresult: {{s}}\n"
}
}
}
}