Practical use of improper lists in Erlang (perhaps all functional languages)

后端 未结 4 1643
时光取名叫无心
时光取名叫无心 2020-12-14 23:16

I\'ve been reading Erlang and OTP in action, and stumbled upon a question with regards to improper lists.

Don’t be tempted to use list cel

4条回答
  •  一个人的身影
    2020-12-14 23:40

    One use suggested by Erlang documentation is faking lazy lists:

    -module(lazy).
    -export([ints_from/1]).
    ints_from(N) ->
        fun() ->
                [N|ints_from(N+1)]
        end.
    

提交回复
热议问题