You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env elvish
use path
if (not-eq (count $args) 1) {
echo "Usage: "(path:base (src)[name])" <input file>" >&2
exit 1
}
var numbers = [(from-lines < $args[0])]
var TARGET = 2020
# Look for pairs of numbers that add to TARGET.
# Then, print the product of those two numbers.
for i [(range (count $numbers))] {
var a = $numbers[$i]
for b $numbers[(+ 1 $i)..] {
if (== (+ $a $b) $TARGET) {
echo (* $a $b)
}
}
}
I can reproduce with elvish built from master branch (commit 9b276a3). Note that while removing one or more lines eliminates the panic adding lines does not.
@xiaq: One thing I noticed is that with the introduction of the new number types the not-eq (count $args) 1 expression in the reproduction script now evaluates to true when the count is, in fact, one. I'll open an issue for that.
I wrote this script:
And ran it with the following input:
I get the following errors:
If you remove one line from that input file, then no exception is generated.
The text was updated successfully, but these errors were encountered: