What task is best done in a functional programming style?

前端 未结 16 1822
-上瘾入骨i
-上瘾入骨i 2020-11-29 17:29

I\'ve just recently discovered the functional programming style and I\'m convinced that it will reduce development efforts, make code easier to read, make software more main

16条回答
  •  误落风尘
    2020-11-29 17:53

    Another example would be the Quicksort algorithm. It can be described very briefly in a functional language like Haskell:

    qsort []     = []
    qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
    

    but needs some more coding in an iterative language. On the referenced Website you can also find a lot of other examples with comparisons between languages.

提交回复
热议问题