Skip to content

syntelos/go-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Comparable GOST for GOPL


  type Ordered interface 

  func Ascending[T Ordered](array []T) ([]T) {

  func Descending[T Ordered](array []T) ([]T) {


Review

  A "traditional" abstraction

    type Comparable interface

    func Sort(array []Comparable) ([]Comparable)

  fails syntactically.

    go test
    # github.com/syntelos/go-sort [github.com/syntelos/go-sort.test]
    ./sort_test.go:61:7: cannot use vector (variable of type TestList) as []Comparable value in argument to Sort
    FAIL	github.com/syntelos/go-sort [build failed]


  The dynamical semantics required are available via
  parametric type abstraction, represented by the "Ordered"
  interface found in [MERO].


Note Bene

  The definition provided currently is a test of conception.

    type Ordered interface {
	    ~int | ~uint | ~string
    }


References

  [GOST] http://pkg.go.dev/sort
  [MERO] https://blog.merovius.de/posts/2024-01-05_constraining_complexity/

Releases

No releases published

Packages

No packages published

Languages