Summing a number to the terms of a list

Jilani Khaldi <>
Tue Aug 12 16:36:43 CEST 2003


Hi All,

Why this code gives me these different results?

-module(sumit).
-export([sum_me/2]).

sum_me(H|T,X) -> [(H+X)|sum_me(T,X)];
sum_me([], X) -> [].

Results:

A=[1,2,3].
sumit:sum_me(A,100).
"efg"

sumit:sum_me(A,200).
"\311\312\313"

sumit:sum_me(A,300).
[301,302,303] -- as I expected.

jilani




More information about the erlang-questions mailing list