Skip to content

Nested for-loops contain an error #37

@skx

Description

@skx

This code works:

function array.sort() {
   let pass = 0;

   for( ! self.sorted?() ) {
      let i = 1;
      let l = len(self);
      for( i < l ) {
         if ( self[i] < self[i-1] ) {
           self = self.swap( i-1, i);
         }
         i++;
      }
      pass +=1;
   }
   return self;
 }

However remove the use of pass and it panics. Seems to be the return-value of the for looks is causing isseus - suspect it doesn't return a value and it should.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions