Data update

This commit is contained in:
Ingy döt Net 2024-03-06 22:25:12 -08:00
parent ed705008a8
commit 0df55f9f24
2196 changed files with 32999 additions and 3075 deletions

View file

@ -0,0 +1,11 @@
:import std/Combinator .
:import std/Number .
:import std/List .
sort y [[0 [[[case-sort]]] case-end]]
case-sort (4 lesser) ++ (2 : (4 greater))
lesser 1 <#> (\les? 2)
greater 1 <#> (\geq? 2)
case-end empty
:test (sort ((+3) : ((+2) : {}(+1)))) ((+1) : ((+2) : {}(+3)))

View file

@ -14,7 +14,7 @@ extension op
auto pivotList := new ArrayList();
auto more := new ArrayList();
self.forEach:(item)
self.forEach::(item)
{
if (item < pivot)
{

View file

@ -0,0 +1,57 @@
recursive subroutine fsort(a)
use inserts, only:insertion_sort !Not included in this posting
implicit none
!
! PARAMETER definitions
!
integer, parameter :: changesize = 64
!
! Dummy arguments
!
real, dimension(:) ,contiguous :: a
intent (inout) a
!
! Local variables
!
integer :: first = 1
integer :: i
integer :: j
integer :: last
logical :: stay
real :: t
real :: x
!
!*Code
!
last = size(a, 1)
if( (last - first)<changesize )then
call insertion_sort(a(first:last))
return
end if
j = shiftr((first + last), 1) + 1
!
x = a(j)
i = first
j = last
stay = .true.
do while ( stay )
do while ( a(i)<x )
i = i + 1
end do
do while ( x<a(j) )
j = j - 1
end do
if( j<i )then
stay = .false.
else
t = a(i) ! Swap the values
a(i) = a(j)
a(j) = t
i = i + 1 ! Adjust the pointers (PIVOT POINTS)
j = j - 1
end if
end do
if( first<i - 1 )call fsort(a(first:i - 1)) ! We still have some left to do on the lower
if( j + 1<last )call fsort(a(j + 1:last)) ! We still have some left to do on the upper
return
end subroutine fsort

View file

@ -0,0 +1,23 @@
$ENTRY Go {
, 7 6 5 9 8 4 3 1 2 0: e.Arr
= <Prout e.Arr>
<Prout <Sort e.Arr>>;
};
Sort {
= ;
s.N = s.N;
s.Pivot e.X =
<Sort <Filter s.Pivot '-' e.X>>
<Filter s.Pivot '=' e.X>
s.Pivot
<Sort <Filter s.Pivot '+' e.X>>;
};
Filter {
s.N s.Comp = ;
s.N s.Comp s.I e.List, <Compare s.I s.N>: {
s.Comp = s.I <Filter s.N s.Comp e.List>;
s.X = <Filter s.N s.Comp e.List>;
};
};

View file

@ -3,26 +3,27 @@ templates quicksort
def first: $(1);
def last: $(2);
def pivot: $@quicksort($first);
[ $first + 1, $last ] -> #
@: $(1) + 1;
$(2) -> #
when <?($(2) <..~$(1)>)> do
def limit: $(2);
when <..~$@> do
def limit: $;
@quicksort($first): $@quicksort($limit);
@quicksort($limit): $pivot;
[ $first, $limit - 1 ] !
[ $limit + 1, $last ] !
when <?($@quicksort($(2)) <$pivot~..>)> do
[ $(1), $(2) - 1] -> #
when <?($@quicksort($) <$pivot~..>)> do
$ - 1 -> #
when <?($@quicksort($(1)) <..$pivot>)> do
[ $(1) + 1, $(2)] -> #
when <?($@quicksort($@) <..$pivot>)> do
@: $@ + 1; $ -> #
otherwise
def temp: $@quicksort($(1));
@quicksort($(1)): $@quicksort($(2));
@quicksort($(2)): $temp;
[ $(1) + 1, $(2) - 1] -> #
def temp: $@quicksort($@);
@quicksort($@): $@quicksort($);
@quicksort($): $temp;
@: $@ + 1; $ - 1 -> #
end partial
@: $;
[1, $@::length] -> #

View file

@ -1,11 +1,11 @@
import "/sort" for Sort
import "./sort" for Sort
var as = [
var array = [
[4, 65, 2, -31, 0, 99, 2, 83, 782, 1],
[7, 5, 2, 6, 1, 4, 2, 6, 3],
["echo", "lima", "charlie", "whiskey", "golf", "papa", "alfa", "india", "foxtrot", "kilo"]
]
for (a in as) {
for (a in array) {
System.print("Before: %(a)")
Sort.quick(a)
System.print("After : %(a)")