05-18-2013, 06:22 AM
nemyax Wrote:I like the first one, but does it introduce too much overhead?Considering what we have here I prefer the 2nd one.
In some situations the 1st can result in a list of list that would require to use lists:flatten to make it a plain list - depending on how you will use it.
(05-17-2013, 12:22 PM)nemyax Wrote: Which is the best recursion method?Always as possible try to use List Comprehensions or - in this case - Bit String Comprehensions - it's faster!
In your case:
Code:
get_indices(Bin) ->
[ I || <<I:16/little>> <= Bin ].
p.s.
1) you don't need to write this full declaration: I:16/unsigned-little-integer
writing just I:16/little will produce the same result and would make your code easy to read.
In accord with Bit Syntax Expressions documentation, unsigned and integer are default value for the type specifier list.
2) It's good see someone else coding for Wings3d.