[erlang-questions] How to understanding recursive inside comprehension lists?

I Gusti Ngurah Oka Prinarjaya okaprinarjaya@REDACTED
Fri Aug 23 14:03:13 CEST 2019


Now I read Joe's book titled Programming Erlang 2nd Edition. I practice
some functions such as for/3, quicksort/1, pythag/1, and perms/1, and
perms/1 is the function that hard to understand.

I understand comprehension lists, I fully understand for/3, I fully
understand quicksort/1, pythag/1. But it's really hard for me to understand
perms/1. Please teach me how to read and understand this perms/1 function.

perms([]) -> [[]];
perms(List) -> [ [H|T] || H <- List, T <- perms(List--[H]) ].

1> lib_misc:perms("123").

Please enlightenment

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190823/eae403d8/attachment.htm>

More information about the erlang-questions mailing list