Jump to content
Mr. Tonci Pirovic

function arguments...

Recommended Posts

Hi,

 

 I'm trying to implement quicksort algorithm to object list with FDouble elements and there are several questions I'm struggling with...In feature quicksort01.fdfc,  function argument forSort seems to be recognized as FObjectList in lines 11 and 15, but not in the foreach statement in line 25...where's the catch?

 

Part of this function should deal with concatenating several object lists into one...In second attached feature concatenateLists.fdfc I've done it with three separate foreach statements...Is there a way to make this more compact, say, in a loop statement?

 

Please advice...

 

Thanks,

Tonci

 

 

 

 

 

 

quickSort01.fdfc

concatenateLists.fdfc

post-132-0-15738400-1404039610_thumb.jpg

post-132-0-48931200-1404039640_thumb.jpg

Share this post


Link to post
Share on other sites

Hello,

 

Well, to be honest this is an error in the feature compiler that has already been fixed in the upcoming 3.1 release. So, I am afraid until that is out, the only thing you can do is to replace the foreach statement with a loop or a while statement, sorry.

 

You could reduce the second concatenation to the following:

objectlist ol1()
objectlist ol2()
objectlist ol3()

objectlist allLists([ol1,ol2,ol3])
objectlist result()

foreach(fobjectlist ol in allLists)
  foreach(fdouble d in ol)
    result.add(d)
  endfor
endfor


But this is only shorter in text, it is neither faster nor more efficient in executing (in fact, it is a tiny little bit smaller... but that is not measurable).

Share this post


Link to post
Share on other sites

I had a look into my old testing project, because I knew, there was one where I implemented a bunch of sort algorithms in features.

 

In the attached project there are implementations of insertionsort, quicksort, selectionsort and mergesort, along with some other testing features. Each algorithm is implemented once with functions and once without. Note, that the features were created before the foreach statement was implemented, so they all use pure loops or whiles... Maybe this helps :)

Share this post


Link to post
Share on other sites

Hi Arne, thank you for these insights...I'm looking forward to new release!

 

...could you please re-upload your testing project, I'm not able to see it...and definitely, it'll be very interesting to explore...

 

Many thanks!

Tonci

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...