functional

GUI Testing

I'm working on the issue of testing my GUI and I'm not entirely sure of the best approach here. My GUI is built using a traditional MVC framework so I am easily able to test the logic parts of the GUI without bringing up the GUI itself. However, when it comes to testing the functionality of the GUI, I'm not really sure if I should worry ...

Nested for loops in different languages

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...

Coming to Ocaml from Ruby, Lisp, Haskell, and Erlang

I've been reading about Ocaml's consistent speed, rapid prototyping ability, and excellent memory management, and decided to take it up. As I've already got Ruby, *lisp, Haskell, and Erlang under my belt, I'm interested specifically in what KISS-violating features I should look out for in Ocaml. If you've started Ocaml with a backgroun...

Correct way to use custom functor with std::generate_n() algorithm?

The following code compiles correctly under VC++ 8 on XPSP3, but running it causes a runtime error. My header looks like: #include <stdexcept> #include <iterator> #include <list> template<typename T> class test_generator { public: typedef T result_type; //constructor test_generator() { std::generate_n( std:...

New to functional programming

...

Haskell string list through lines

Hey, I'm using the lines functionality to take an input and split up many variables before sending it off to a function. Please look at the run function and tell me why I get the following error. It seems like it should just assign the first string in ln to seq, but I get an error. ERROR:dishonest.hs:33:11: Couldn't match expecte...

tr1::mem_fn and tr1::bind: on const-correctness and overloading

What's wrong with the following snippet ? #include <tr1/functional> #include <functional> #include <iostream> using namespace std::tr1::placeholders; struct abc { typedef void result_type; void hello(int) { std::cout << __PRETTY_FUNCTION__ << std::endl; } void hello(int) const { std::cout << __PRETTY_FUNCTION__ <...

What is your favorite Delphi open source functional testing tool?

I'm aware of Selenium which is a very good open source automated website testing tool. Is there any equivalent open source tool to provide functional testing for Win32 GUI Delphi Applications? After a quick Google I've found this one : EFT So my question is what is your favourite functional testing tool and why? ...

List of strings to one string

Lets say you have a: List<string> los = new List<string>(); In this crazy functional world we live in these days which one of these would be best for creating one string by concatenating these: String.Join(String.Empty, los.ToArray()); StringBuilder builder = new StringBuilder(); los.ForEach(s => builder.Append(s)); string disp = l...

J2ME development without Java?

I'm making my first foray into the J2ME world. I'd prefer to use a functional language to do the development. Scala used to have CLDC support, but it's no longer maintained. Bigloo seems to have disappeared. Interpreters (such as Jython) are a no-go, since J2ME apps have to be small (at least, mine has to be). I would like to know of ...

How can I pre-set arguments in JavaScript function call? (Partial Function Application)

I am trying to write a JavaScript function that will return its first argument(function) with all the rest of its arguments as preset parameters to that function. So: function out(a, b) { document.write(a + " " + b); } function setter(...) {...} setter(out, "hello")("world"); setter(out, "hello", "world")(); Would output "hello...

Symbolic simplification in Haskell (using recursion?)

How can I give a general rule that includes all the expressions below? E.g one expression, another one for sub and one for mult. I need to use recursion but i got confused... simplify :: Expr->Expr simplify (Mult (Const 0)(Var"x")) = Const 0 simplify (Mult (Var "x") (Const 0)) = Const 0 simplify (Plus (Const 0) (Var "x")) = Var "x"...

How do I simplify the below expressions using primitive recursion ?

The simplifications I have in mind are 0*e = e*0 = 0 1*e = e*1 = 0+e = e+0 = e-0 = e and simplifying constant subexpressions, e.g. Plus (Const 1) (Const 2) would become Const 3. I would not expect variables (or variables and constants) to be concatenated: Var "st" is a distinct variable from Var "s". For example simplify(Plus (Var "...

JUnit 4: Set up things in a test suite before tests are run (like a test's @BeforeClass method, just for a test suite)

I want to do some functional testing on a (restful) webservice. The testsuite contains a bunch of test cases, each of which performs a couple of HTTP requests on the webservice. Naturally, the webservice has to run or the tests will fail. :-) Starting the webservice takes a couple of minutes (it does some heavy data lifting), so I want...

What are your feelings on functional specs? And Software design?

Does the functional spec help or hinder your expectations? Do programmers who practice the waterfall methodology, are they open to functional specs? I'm a web designer/developer working with a team of 5 programmers and would like to write a functional spec to explain what we need, so that when I begin my work - I know we are working towa...

What are some examples of LISP being used in production, outside of AI and academia?

Possible Duplicate: Lisp in the real world A search query on Google reveals that the search term 'practical lisp' returns a link for Practical Common LISP, which is a very nice starter book. However, this is not what I was looking for or had in mind when I set out to search those terms. ...

Evaluation of part of Clojure cond

Trying to do exercise 1.16 (iterative version of fast-exp) in "Structure and Interpretation of Computer Programs" with Clojure I came up with this: (defn fast-it-exp [base exp res] (cond (= exp 0) res (odd? exp) fast-it-exp base (- exp 1) (* base res) :else fast-it-exp base (/ exp 2) (* base base res))) Trying it out: user=> (f...

How to properly test this controller action with Shoulda?

I have the following controller action and test. I'm new to testing with Shoulda and I know there are areas of my controller that I can test further. For example, my flash messages as well as verifying the renders. So my question is, how would I properly test this controller action in Shoulda? My controller action (names have been ch...

closures and objects

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...

Are functional languages inherently slow?

Why are functional languages always tailing behind C in benchmarks? If you have a statically typed functional language, it seems to me it could be compiled to the same code as C, or to even more optimized code since more semantics are available to the compiler. Why does it seem like all functional languages are slower than C, and why d...