3 ms·
Pedant: That’s not imperative. You can have a purely functional program that uses a flag in a list to treat subsequent arguments in a list differently. Just hav
by rayiner 4y ago
Pedant: That’s not imperative. You can have a purely functional program that uses a flag in a list to treat subsequent arguments in a list differently. Just have a conditional on the flag, and recursively call “do_things_this_way” on one branch and “do_things_that_way” on the other.
- skissane 4y agoPedant: You can have a purely functional program which is an interpreter for BASIC or COBOL or FORTRAN (at least for batch/non-interactive programs, although it may depend on exactly what you mean by “pure”.) Does that mean, since those languages can be correctly interpreted by a purely functional program, that they aren’t “imperative”?
- carstimon 4y agohttps://aphyr.com/posts/353-rewriting-the-technical-interview https://aphyr.com/posts/353-rewriting-the-technical-intervie...
- LegionMammal978 4y agoI think the comparison here is imperative (i.e., stateful and sequential) vs. declarative (i.e., stateless), not declarative vs. functional.
- xg15 4y agoI think there is no clear boundary where "order dependant" ends and "imperative" begins, but it's at least pretty unusual to use the same flag - or even mutually excluding flags! - together multiple times in the same invocation. I think as a rule of thumb, if you have to mentally keep track of some internal data structure to make sense of your invocation, you're usually pretty deep in "imperative" territory. > and recursively call “do_things_this_way” on one branch and “do_things_that_way” on the other. That's the usual algorithm by which imperative logic is translated into equivalent functional logic though. We know for about as long as computers exit that the two are equivalent in terms of computational power - in the sense that any imperative program can be translated into a functional program that does the same thing and vice versa. That doesn't mean the two programs are identical though.