Find the sum of a non-empty numeric vector v without using the character + . Currently, 10 essentially different solutions are listed below.
Spoiler Alert!
Solutions
Expression |
Comment |
".(43{a.)'/v' |
a "cheat" |
(--)/v |
the dyad (--) is plus |
-/v*(#v)$1 _1 |
alternating sum |
1#.v |
power series evaluated at 1 |
v%.1 |
|
*&.^/v |
works if v are real numbers |
#v#1 |
works if v are non-negative integers |
>:@[&0/v |
works if v are non-negative integers |
(>:@$: <:)`[@.(0=])/v |
works if v are non-negative integers; based on the Peano axioms |
((*.,0:) $:&#. ~:)/@#:@,^:(0<[)/v |
works if v are non-negative integers; implements addition on binary representations |
