tensort-1.0.1.4: Tunable sorting for responsive robustness and beyond
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Tensort.Robustsort

Description

This module provides variations of the Robustsort algorithm using the custom Sortable type for inputs and outputs

Synopsis

Documentation

robustsortP :: Sortable -> Sortable Source #

Takes a Sortable and returns a sorted Sortable using a Basic Mundane Robustsort algorithm with a Permutationsort adjudicator

Examples

Expand
>>> robustsortP (SortBit [16, 23, 4, 8, 15, 42])
SortBit [4,8,15,16,23,42]
>>> robustsortP (SortRec [(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)])
SortRec [(2,4),(3,8),(0,15),(1,16),(5,23),(4,42)]

robustsortB :: Sortable -> Sortable Source #

Takes a Sortable and returns a sorted Sortable using a Basic Mundane Robustsort algorithm with a Bogosort adjudicator

Examples

Expand
>>> robustsortB (SortBit [16, 23, 4, 8, 15, 42])
SortBit [4,8,15,16,23,42]
>>> robustsortB (SortRec [(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)])
SortRec [(2,4),(3,8),(0,15),(1,16),(5,23),(4,42)]

robustsortM :: Sortable -> Sortable Source #

Takes a Sortable and returns a sorted Sortable using a Basic Magic Robustsort algorithm

Examples

Expand
>>> robustsortM (SortBit [16, 23, 4, 8, 15, 42])
SortBit [4,8,15,16,23,42]
>>> robustsortM (SortRec [(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)])
SortRec [(2,4),(3,8),(0,15),(1,16),(5,23),(4,42)]

robustsortRCustom :: SortAlg -> Sortable -> Sortable Source #

Used for making recursive Robustsort variants

Takes the base SortAlg you want to use and a Sortable and returns a sorted Sortable.

Uses a Logarithmic bytesize to determine when to stop recursing and use the base SortAlg to sort the records.

Uses the base SortAlg once the bytesize is less than or equal to 27. This number is chosen because the natural logarithm of 27 is close to 3 (it's about 3.3) and the cube root of 27 is 3, so it's likely to be an efficient choice.

This configuration is tailored to using a standard basic Robustsort algorithm (i.e. with a Bytesize of 3) as the base SortAlg. You're welcome to experiment with weirder setups too!

Examples

Expand
>>> robustsortRCustom robustsortB (SortBit [16, 23, 4, 8, 15, 42])
SortBit [4,8,15,16,23,42]
>>> robustsortRCustom robustsortB (SortRec [(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)])
SortRec [(2,4),(3,8),(0,15),(1,16),(5,23),(4,42)]

robustsortRP :: Sortable -> Sortable Source #

Takes a Sortable and returns a sorted Sortable using a Recursive Mundane Robustsort algorithm with a Permutationsort adjudicator

Examples

Expand
>>> robustsortRP (SortBit [16, 23, 4, 8, 15, 42])
SortBit [4,8,15,16,23,42]
>>> robustsortRP (SortRec [(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)])
SortRec [(2,4),(3,8),(0,15),(1,16),(5,23),(4,42)]

robustsortRB :: Sortable -> Sortable Source #

Takes a Sortable and returns a sorted Sortable using a Recursive Mundane Robustsort algorithm with a Bogosort adjudicator

Examples

Expand
>>> robustsortRB (SortBit [16, 23, 4, 8, 15, 42])
SortBit [4,8,15,16,23,42]
>>> robustsortRB (SortRec [(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)])
SortRec [(2,4),(3,8),(0,15),(1,16),(5,23),(4,42)]

robustsortRM :: Sortable -> Sortable Source #

Takes a Sortable and returns a sorted Sortable using a Recursive Magic Robustsort algorithm

Examples

Expand
>>> robustsortRM (SortBit [16, 23, 4, 8, 15, 42])
SortBit [4,8,15,16,23,42]
>>> robustsortRM (SortRec [(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)])
SortRec [(2,4),(3,8),(0,15),(1,16),(5,23),(4,42)]