Summing a number to the terms of a list

Vance Shipley <>
Tue Aug 12 17:03:12 CEST 2003


Jilani,

They're not really different they're just displayed diofferent.

>From the wonderful new Erlang Reference Manual:

	2.11 String

	Strings are enclosed in double quotes ("), but is not
	a data type in Erlang. Instead a string "hello" is
	shorthand for the list [$h,$e,$l,$l,$o], that is
	[104,101,108,108,111].

   -Vance


On Tue, Aug 12, 2003 at 04:36:43PM +0200, Jilani Khaldi wrote:
}  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