I have a list L = [1,2,3].
I perform the following on L:
lists:sublist(L,2) ++ [10] ++ lists:nthtail(3,L).
Instead of storing the result in a new list, I want to store the result in L itself. However, when I do so, I am getting the obvious error: ** exception error: no match of right hand side value [1,2,300]
I don't want to use a new variable, I want to rewrite in L itself. Is it possible?
1条答案
按热度按时间2mbi3lxu1#
不,Erlang有single assignment。要使用example from Armstrong,在C中可以这样做:
但在爱尔兰语中,它是这样写的: