Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Share Thread:
Reddit Facebook Twitter
Tidy recursion
05-18-2013, 06:22 AM
Post: #2
RE: Tidy recursion
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 ].
Simple like that!

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. Smile
Reply


Messages In This Thread
Tidy recursion - nemyax - 05-17-2013, 12:22 PM
RE: Tidy recursion - micheus - 05-18-2013 06:22 AM
RE: Tidy recursion - nemyax - 05-19-2013, 09:14 PM
RE: Tidy recursion - dgud - 05-20-2013, 01:50 PM
RE: Tidy recursion - micheus - 05-20-2013, 01:58 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)