2008
08.16

这么简洁漂亮的语法都能创造出来,真的服了,着迷啊着迷!

double([H|T]) -> [2*H|double(T)];
double([])    -> [].

> double([1,2,3,4]).
[2,4,6,8]

add_one([H|T]) -> [H+1|add_one(T)];
add_one([])    -> [].

map(F, [H|T]) -> [F(H)|map(F, T)];
map(F, [])    -> [].

double(L)  -> map(fun(X) -> 2*X end, L).
add_one(L) -> map(fun(X) -> 1 + X end, L).

9 comments so far

Add Your Comment
  1. Jack on August 19, 2008 at 10:11 am  

    (Quote)
    said:

    Michael你好,很幸运能找到你的博客。

    我一直在学习做网站,之前重点在前台。现在我想学习更…

    很高兴和你交流,一起提高。 你提到的这种综合性的书,不太好找,国外有本书叫 High proformance website ,感觉对部分细节和基础部分的东西讲得还凑合,但是还是不够全面,可以去书店先看看感受一下。

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word