September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -0,0 +1,16 @@
begin
% use the quicksort procedure from the Sorting_Algorithms/Quicksort task %
% Quicksorts in-place the array of integers v, from lb to ub - external %
procedure quicksort ( integer array v( * )
; integer value lb, ub
) ; algol "sortingAlgorithms_Quicksort" ;
% sort an integer array with the quicksort routine %
begin
integer array t ( 1 :: 5 );
integer p;
p := 1;
for v := 2, 3, 1, 9, -2 do begin t( p ) := v; p := p + 1; end;
quicksort( t, 1, 5 );
for i := 1 until 5 do writeon( i_w := 1, s_w := 1, t( i ) )
end
end.

View file

@ -1,9 +1,9 @@
import system'routines.
import extensions.
import system'routines;
import extensions;
program =
[
var unsorted := (6, 2, 7, 8, 3, 1, 10, 5, 4, 9).
public program()
{
var unsorted := new int[]{6, 2, 7, 8, 3, 1, 10, 5, 4, 9};
console printLine(unsorted clone; sort:ifOrdered).
].
console.printLine(unsorted.clone().sort(ifOrdered).asEnumerable())
}

View file

@ -1,6 +1,6 @@
import java.util.Arrays;
public class example {
public class Example {
public static void main(String[] args)
{
int[] nums = {2,4,3,1,2};

View file

@ -2,7 +2,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class example {
public class Example {
public static void main(String[] args)
{
List<Integer> nums = Arrays.asList(2,4,3,1,2);

View file

@ -0,0 +1,40 @@
/**
<doc><h2>Sort integer array, in Neko</h2>
<p>Array sort function modified from Haxe codegen with -D neko-source</p>
<p>The Neko target emits support code for Haxe basics, sort is included</p>
<p>Tectonics:<br />prompt$ nekoc sort.neko<br />prompt$ neko sort</p>
</doc>
**/
var sort = function(a) {
var i = 0;
var len = $asize(a);
while ( i < len ) {
var swap = false;
var j = 0;
var max = (len - i) - 1;
while ( j < max ) {
if ( (a[j] - a[j + 1]) > 0 ) {
var tmp = a[j + 1];
a[j + 1] = a[j];
a[j] = tmp;
swap = true;
}
j += 1;
}
if ( $not(swap) )
break;;
i += 1;
}
return a;
}
var arr = $array(5,3,2,1,4)
$print(arr, "\n")
/* Sorts in place */
sort(arr)
$print(arr, "\n")
/* Also returns the sorted array for chaining */
$print(sort($array(3,1,4,1,5,9,2,6,5,3,5,8)), "\n")