perlgolf hole - Addition without Addition

Hole type: subroutine

Write a subroutine which, passed a list of non-negative integers, returns the sum of the numbers, without using any addition or subtraction operators ( + - ++ -- += -= ).

Solutions

CodeLength
sub hole {my$x;$x.=1x$_ for@_;length$x}28
sub hole {my@x;push@x,(0)x$_ for@_;@x}27
sub hole {map{(0)x$_}@_}13

Comments

This hole is rather tricky, because it's so easy for a + or - to slip in to your solution. For example, one of the committee members came up with sub hole {$r=shift;for(@_){$r*=(1+$_/$r)};$r}, which is clever, but unfortunately does use the addition operator.

The key to this hole is calculating the sum in unary mode. While binary mode has two digits and decimal mode has ten, unary mode has only one. After having built up a string or array in unary, the length/size is the sum.

This was one of my favorite holes, and would have been the last hole in the tournament at the conference.