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

Data.Tensort.Tensort

Description

This module provides variations of the Tensort algorithm

Synopsis

Documentation

tensort :: Ord a => TensortProps a -> [Bit a] -> [Bit a] Source #

Sort a list using a custom Tensort algorithm

Takes TensortProps (Bytesize and SubAlgorithm) and a list and returns a sorted list

Examples

Expand
>>> import Data.Tensort.Subalgorithms.Bubblesort (bubblesort)
>>> import Data.Tensort.Utils.MkTsProps (mkTsProps)
>>> tensort (mkTsProps 2 bubblesort) ([16, 23, 4, 8, 15, 42] :: [Int])
[4,8,15,16,23,42]
>>> tensort (mkTsProps 2 bubblesort) ([(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)] :: [(Int, Int)])
[(0,15),(1,16),(2,4),(3,8),(4,42),(5,23)]

tensortB4 :: Ord a => [Bit a] -> [Bit a] Source #

Sort a list using a Standard Tensort algorithm with a 4-Bit Bytesize

Examples

Expand
>>> tensortB4 ([16, 23, 4, 8, 15, 42] :: [Int])
[4,8,15,16,23,42]
>>> tensortB4 ([(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)] :: [(Int, Int)])
[(0,15),(1,16),(2,4),(3,8),(4,42),(5,23)]

tensortBN :: Ord a => Int -> [Bit a] -> [Bit a] Source #

Sort a list using a Standard Tensort algorithm with a custom Bytesize

Examples

Expand
>>> tensortBN 3 ([16, 23, 4, 8, 15, 42] :: [Int])
[4,8,15,16,23,42]
>>> tensortBN 3 ([(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)] :: [(Int, Int)])
[(0,15),(1,16),(2,4),(3,8),(4,42),(5,23)]

tensortBL :: Ord a => [Bit a] -> [Bit a] Source #

Sort a list using a Standard Logarithmic Tensort algorithm

Standard Logarithmic Tensort uses a Bytesize that approximates the natural logarithm of the length of the input list and a Bubblesort subalgorithm

Examples

Expand
>>> tensortBL ([16, 23, 4, 8, 15, 42] :: [Int])
[4,8,15,16,23,42]
>>> tensortBL ([(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15) , (4, 42)] :: [(Int, Int)])
[(0,15),(1,16),(2,4),(3,8),(4,42),(5,23)]