O,Given a set of integers, find the sum of all integers in it.
Try it online!
O,... # trimmed program
, # output...
O # sum of...
# implicit input...
, # explicitly to prevent the fatal error from stopping implicit output
... # no-op as implicit output has been canceled by the print command and the rest of the code doesn't contain any more print commands
In case you're curious, the error occurs because of G
, and because the item on top of the stack is a list. G
is a loop, looping the variable N
through the list [1, 2, 3, ..., top of stack - 1]
. Since ,
pops the item on top of the stack before printing, G
has no arguments to use and instead uses implicit input. Since you can't subtract a number from a list, it errors.
Alternatively, replacing the second character (,
) with one of these, combined with optionally removing the G
, will also work:
? # erroring solution - with G
= # non-erroring solution - with G
, # non-erroring solution - without G
? # non-erroring solution - without G
= # non-erroring solution - without G
D # non-erroring solution - without G