Logo

Programming-Idioms

  • Scheme
  • Ruby
s = x.reduce(:+)

This was idiomatic before Ruby 2.4
s = x.sum

Works since Ruby 2.4
(define s (apply + x))
(define s (apply + x))
(define s (foldr + 0 x))
(define s (fold-right + 0 x))

Chez Scheme
(define s (apply fx+ x))

fx+ is integer (fixnum) operation
for E of x loop
   S := S + E;
end loop;

x is an array.
S is initialized to be 0.

New implementation...
< >
deleplace