1. Yuya Nishihara
  2. playground

Commits

Yuya Nishihara  committed aa3d323

haskell: example of recursion

  • Participants
  • Parent commits 7e51f6e
  • Branches default

Comments (0)

Files changed (1)

File haskell/recursion.hs

View file
+factorial :: Int -> Int
+factorial n
+  | n <= 0 = 1
+  | otherwise = n * factorial (n - 1)
+
+quicksort :: (Ord a) => [a] -> [a]
+quicksort [] = []
+quicksort (x:xs) =
+  quicksort smallerOrEqual ++ [x] ++ quicksort larger
+  where smallerOrEqual = [e | e <- xs, e <= x]
+        larger = [e | e <- xs, e > x]