forked from steger/pr3-ws202627
45 lines
1.2 KiB
Haskell
45 lines
1.2 KiB
Haskell
import Data.Bits (Bits (xor))
|
||
|
||
-- single parameter
|
||
mySquare :: (Num a) => a -> a
|
||
mySquare x = x * x
|
||
|
||
-- mySign x = if x < 0 then -1 else if x > 0 then 1 else 0
|
||
|
||
-- two parameters
|
||
|
||
-- ============= pattern matching =================
|
||
-- mySign :: Int -> Int
|
||
-- mySign 0 = 0
|
||
-- mySign x = if x < 0 then -1 else 1
|
||
-- ============= guards =================
|
||
|
||
mySign x
|
||
| x > 0 = 1
|
||
| x < 0 = -1
|
||
| x == 0 = 0
|
||
|
||
-- ============= recursive algorithms =================
|
||
|
||
-- ============= recursive list algorithms =================
|
||
|
||
-- ============= merge sort =================
|
||
|
||
-- =========== Filter all numbers that can be divided by 10 ===========
|
||
|
||
-- ========================== standard deviation using lambdas =====================
|
||
-- The standard deviation is a measure of the amount of variation or dispersion of a set of values.
|
||
-- It is defined as the square root of the average of the squared differences from the mean.
|
||
--
|
||
-- Formula:
|
||
-- σ = sqrt( (1/N) * Σ (xi - μ)^2 )
|
||
-- where:
|
||
-- - σ is the standard deviation,
|
||
-- - N is the number of values,
|
||
-- - xi represents each value,
|
||
-- - μ is the mean of the values.
|
||
|
||
stddev seq = 0
|
||
|
||
-- ======================= order list of strings by length =================
|