erlang的shell里写一个尾递归

    xiaoxiao2025-03-22  20

    定时打印消息

    1> FLoop = fun(Pid)-> Lfun = fun(F,Pid) -> receive loop->io:format("test",[]),erlang:send_after(1000,Pid,loop),F(F,Pid) end end,Lfun(Lfun,Pid) end.

    2> spawn(fun()-> FLoop(self()) end).                                                                                              

    3> erlang:send(v(2), loop).

    其他相关:

    http://stackoverflow.com/questions/867418/how-do-you-write-a-fun-thats-recursive-in-erlang/867525

    转载请注明原文地址: https://ju.6miu.com/read-1297269.html
    最新回复(0)