Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this abstract data type called?

I'm writing Haskell, but this could be applied to any OO or functional language with a concept of ADT. I'll give the template in Haskell, ignoring the fact that the arithmetic operators are already taken:

class Thing a where
   (+) :: a -> a -> a
   (-) :: a -> a -> a
   x - y = x + negate y
   (*) :: (RealFrac b) => a -> b -> a
   negate :: a -> a
   negate x = x * (-1)

Basically these are things that can be added and subtracted and also multiplied by real fractional values. One example might be a simple list of numbers: addition and subtraction are pairwise (in Haskell, "(+) = zipWith (+)"), and multiplication by a real multiplies every item in the list by the same amount. I've come across enough other examples to want to define it as a class, but I don't know exactly what to call it.

In Haskell its usually a monoid provided there is some kind of zero value.

Is this some known kind of object in the zoo of algebraic types? I've looked through rings, semirings, nearsemirings, groups etc without finding it.

like image 284
Paul Johnson Avatar asked May 30 '26 02:05

Paul Johnson


1 Answers

This is a vector space: http://en.wikipedia.org/wiki/Vector_space. You have addition and scalar multiplication.

like image 190
sclv Avatar answered Jun 01 '26 17:06

sclv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!