• Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Social Media
    •   @Wings3dOfficial
    •   @Wings3dOfficial
    •   Wings3dOfficial
    •   Wings3dOfficial
  • Register
  • Login
  • Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Register
  • Login
Wings 3D Development Forum Wings 3D Programming v
« Previous 1 2 3 4
Tidy recursion

 
  • 0 Vote(s) - 0 Average
Tidy recursion

micheus
Offline

Forum's Admin and Support | Bug fixer
Posts: 3,675
Threads: 183
Joined: Jun 2012
#2
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 ].
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
« Next Oldest | Next Newest »

Users browsing this thread: 4 Guest(s)



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

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D - Powered by MyBB

Linear Mode
Threaded Mode