Skip to main content
result = 0
for num in numbers:
    if pred(resultnum):
        result += num
return result
result = 0
for num in numbers:
    if pred(result):
        result += num
return result
result = 0
for num in numbers:
    if pred(num):
        result += num
return result
Commonmark migration
Source Link

###What is it in functional programming that makes a difference?

What is it in functional programming that makes a difference?

###So, are variables and loops wrong?

So, are variables and loops wrong?

###Summary

Summary

###What is it in functional programming that makes a difference?

###So, are variables and loops wrong?

###Summary

What is it in functional programming that makes a difference?

So, are variables and loops wrong?

Summary

edited body
Source Link
Frax
  • 1.9k
  • 13
  • 16
sum pred list = 
    case predlist of
        [] -> 0
        h:t -> if pred h then h + sum pred t
                         else sum pred t

VariablesThere are many things that are much easier explained by them, and many algorithms that require mutable state to be fast. But variables are inherently imperative, explaining how instead of what, and giving little prediction of what their value may be a few lines later or after a few loop iterations. Loops generally require state to make sense, and so they are inherently imperative as well. But there are many things that are much easier explained by them, and many algorithms that require mutable state to be fast.

sum pred list = 
    case pred of
        [] -> 0
        h:t -> if pred h then h + sum pred t
                         else sum pred t

Variables are inherently imperative, explaining how instead of what, and giving little prediction of what their value may be a few lines later or after a few loop iterations. Loops generally require state to make sense, and so they are inherently imperative as well. But there are many things that are much easier explained by them, and many algorithms that require mutable state to be fast.

sum pred list = 
    case list of
        [] -> 0
        h:t -> if pred h then h + sum pred t
                         else sum pred t

There are many things that are much easier explained by them, and many algorithms that require mutable state to be fast. But variables are inherently imperative, explaining how instead of what, and giving little prediction of what their value may be a few lines later or after a few loop iterations. Loops generally require state to make sense, and so they are inherently imperative as well.

Middle section separated and rephrased.
Source Link
Frax
  • 1.9k
  • 13
  • 16
Loading
formatting, removed unnecessary picking
Source Link
Frax
  • 1.9k
  • 13
  • 16
Loading
deleted 70 characters in body
Source Link
Frax
  • 1.9k
  • 13
  • 16
Loading
formatting
Source Link
Frax
  • 1.9k
  • 13
  • 16
Loading
typo
Source Link
Frax
  • 1.9k
  • 13
  • 16
Loading
Source Link
Frax
  • 1.9k
  • 13
  • 16
Loading