Here is a fairly common problem. We have an array of arrays. We'd like to call some function for every combination of elements from the different arrays. Conceptually we'd like to do something like this:
for my $x (1, 2) {
for my $y ('a', 'b') {
for my $z ('A', 'B') {
print "$x $y $z\n";
}
}
}
except that we don't...
Can you provide examples of applications today that are procedural and maintain a high level of integrity and efficiency? Are there any books, tutorials or links that provide examples of how to successfully build and maintain an imperative system? If you were to give guidance in this area, what tips would you give on how it should be str...
Functional programming .. is like classic ( Mark Twain's type).
While reading another articles about SICP, where people are talking about
the great impact closures had on there thinking, i got reminded of this,
which i read ages ago
Closures are poor man's objects
Objects are poor man's closure
( Can't recall exact source but it was pr...
Which techniques or paradigms normally associated with functional languages can productively be used in imperative languages as well?
e.g.:
Recursion can be problematic in languages without tail-call optimization, limiting its use to a narrow set of cases, so that's of limited usefulness
Map and filter have found their way into non-fu...
Hi all,
When implementing a class, is it better practice to return a value for methods (interrogative) or to simply manipulate class attributes directly within the method (imperative).
For example, I have a class which builds a string to be output to a CSV file. I might do it this way:
String output = ""
String records[] = //list of ...
I'm reading 'Functional Programming' by Tomas Petricek & Jon Skeet and I understand the difference between declarative & imperative programming.
What I was wondering is how are the primitive operators & functions implemented, are declarative languages constructed from imperative operators & functions.
Cheers
AWC
...
I've got the following problem: I have a tree of objects of different classes where an action in the child class invalidates the parent. In imperative languages, it is trivial to do. For example, in Java:
public class A {
private List<B> m_children = new LinkedList<B>();
private boolean m_valid = true;
public void invalidat...
I'm new to Scala and was just reading Scala By Example. In chapter 2, the author has 2 different versions of Quicksort.
One is imperative style:
def sort(xs: Array[Int]) {
def swap(i: Int, j: Int) {
val t = xs(i); xs(i) = xs(j); xs(j) = t
}
def sort1(l: Int, r: Int) {
val pivot = xs((l + r) / 2)
var ...