functional-programming

excel vba: functions as arguments of functions

There is no special type for functions, therefore it is hard for me to see, how to add functions as arguments to functions in excel vba. What I try to accomplish is something like this: function f(g as function, x as string) as string f = g(x) end function Concerning the motivation: I have a masse of little functions all repe...

How to make a C# 'grep' more Functional using LINQ?

I have a method that performs a simplistic 'grep' across files, using an enumerable of "search strings". (Effectively, I'm doing a very naive "Find All References") IEnumerable<string> searchStrings = GetSearchStrings(); IEnumerable<string> filesToLookIn = GetFiles(); MultiMap<string, string> references = new MultiMap<string, string>(...

How do I combine monads in Haskell?

Particularly, I need to be able to combine the CGI monad with the IO monad, but an example of how to combine the IO monad with the Maybe monad might be even better... ...

return a number with the first X bits set

what is a more efficient way to accomplish this in clojure: (defn ones ([n] (ones n 1 1)) ([n i res] (if (< i n) (recur n (inc i) (bit-set res i)) res))) preferably it should still "do the right thing" when it comes to numerical type. ...

Organizing Clojure Code

I have a program that draws shapes on an image. I have a separate namespace for each shape, and they are in separate files. com/name/box.clj --> has com.name.box namespace. com/name/triangle.clj --> has com.name.triangle namespace. They all share a common function called generate that draws them on screen, so if I use use, function nam...

jquery adds own events/functions to html elements of choice???

is it possible to add to an element type or maybe a css selection an own event function? something like: $("a").bind("blub", function() { alert("aaa" + this); }); $("a").get(0).blub(); i want define some functions which are only available for some special elements eg.: the <div class="myDivContainer">...</div> should have the func...

How to write the Average Function for this Data structure in Scheme/Lisp?

I want to find the price of a new-item based on the average prices of similar items. The function get-k-similar uses k-Nearest Neighbors but returns me this output ((list rating age price) proximity). For example, 2-similar would be: (((5.557799748150248 3 117.94262493533647) . 3.6956648993026904) ((3.0921378389849963 7 75.614925605968...

Functional programming in nuclear plants?

After reading this question I just wondered whether it would be a good idea to use Haskell (or other functional programming languages) in mission critical industries. Apart from Erlang, most languages followed imperative/design-by-contract paradigms (Ada, Eiffel, C++). But what about the functional ones? The resulting code would be e...

BigInt for Standard ML/NJ

Is there a Java BigInt equivalent for Standard ML? The normal int type throws an exception when it overflows. ...

How do I Pass a Function as a Parameter in Emacs?

I'm trying to add a function I created to a hook, but the obvious (to my Schemer mind) way doesn't seem to work. The function is used in 2 places and I want to keep my code DRY so no anonymous function. Though I could wrap my function in a lambda, there must be a better way. Doesn't work: (defun my-function () ;; do my stuff) (add-...

At what level to apply functional programming approach

Should one apply functional programming practices at the design level, i.e. when we identify and design class hierarchy, or is it applicable only when it comes to writing function bodies? What I feel is that we do the design process applying normal OOPs techniques and write implementations using a functional approach. Your thoughts, pl...

Besides a declarative language, is SQL a functional language?

Why yes or why not? ...

Good Source for Learning How to Work with XML in F#

Does anyone have a good source for learning how to work with XML in F#? Multiple sources would be nice if available. ...

Mapping over multiple Seq in Scala

Suppose I have val foo : Seq[Double] = ... val bar : Seq[Double] = ... and I wish to produce a seq where the baz(i) = foo(i) + bar(i). One way I can think of to do this is val baz : Seq[Double] = (foo.toList zip bar.toList) map ((f: Double, b : Double) => f+b) However, this feels both ugly and inefficient -- I have to convert both...

In functional list manipulation, what do we call "inserting something between each item"?

Occasionally I find I need to process a list by inserting a new item after each item, except the last one. Similar to how you might put a comma between each item of a list of strings. I got fed up of coding the special case for the last (or first) item every time, so I captured the pattern in a Linq-style extension: public static IEnum...

Values inside monads, nested in data structures?

Suppose that in a Haskell program I have some data whose type is something like: IO [ IO (Int, String, Int) ], or IO [ (Int, String, IO Int) ], or [ (Int, String, IO Int) ] but I have pure functions that should operate on [ (Int, String, Int) ]. It seems that I'd have to clumsily remove the inside values from the IO monad, until I g...

Which Function is the best in terms of Stack Usage Efficiency and Time.

I wrote 3 functions that count the number of times an-element appears in a-list. I tried various inputs and profiled it but I still dont know which function is the best in terms of stack usage efficiency and time efficiency. Please Help me out. ;; Using an accumulator (defn count-instances1 [a-list an-element] (letfn [(cou...

Functional programming applied

I have been interested in programming all my life and for the past 6 years I have worked almost exclusively with Java. I just finished with my University studies and have a job as a Java developer for a company. All these years programming has been a hobby and a favorite past time, but this had a slightly negative effect in the sense th...

Editor for programming ML on windows?

I know I can use Emacs but I haven't used it earlier... are there any other alternatives?? Thanks ...

Continuations in Clojure.

I read somewhere where rich hickey said: "I think continuations might be neat in theory, but not in practice" I am not familiar with clojure. 1. Does clojure have continuations? 2. If no, dont you need continuations? I have seen a lot of good examples especially from this guy. What is the alternative? 3. If yes, is there a docu...