I have always thought that functional programming can be done in Python. Thus, I was surprised that Python didn't get much of a mention in this question, and when it was mentioned, it normally wasn't very positive. However, not many reasons were given for this (lack of pattern matching and algebraic data types were mentioned). So my ques...
I've been reading a lot of stuff about functional programming lately, and I can understand most of it, but the one thing I just can't wrap my head around is stateless coding. It seems to me that simplifying programming by removing mutable state is like "simplifying" a car by removing the dashboard: the finished product may be simpler, b...
Scheme uses a single namespace for all variables, regardless of whether they are bound to functions or other types of values. Common Lisp separates the two, such that the identifier "hello" may refer to a function in one context, and a string in another.
(Note 1: This question needs an example of the above; feel free to edit it and add ...
I am learning Scala and exploring some of the functional aspects of the language.
Starting with a list of objects containing two parameters notional and currency, how can I aggregate the total notional per currency?
//sample data
val t1 = new Trade("T150310", 10000000, "GBP");
val t2 = new Trade("T150311", 10000000, "JPY");
val t3 = ne...
These days I'm getting seriously into functional programming.
While I'm really excited about Haskell and the possibilities it seems to offer, I can also see now that it is going to take me a while to learn. In an SO question on How to learn Haskell an answer states that it'll take months if not years to actually "master" it.
Now, I kn...
What does it mean in practice? What is non-reactive programming? Wikipedia has quite abstract description of it.
...
I can't seem to find decent documentation on haskell's POSIX implementation.
Specifically the module Text.Regex.Posix.
Can anyone point me in the right direction of using multiline matching on a string?
A snippet for the curious:
> extractToken body = body =~ "<textarea[^>]*id=\"wpTextbox1\"[^>]*>(.*)</textarea>" :: String
I'm tryi...
Functional programming has been around since at least 1958 (creation of Lisp), but is experiencing a renaissance now with old functional languages being dusted off and new functional languages being created.
Which functional languages are there that are newly developed or are in the making?
I realize that you can write purely functio...
I have Clojure function that takes a sequence of numbers chops it into the appropriate number of bits and returns a lazy sequence of the chunks (lowest order bits first). It pads the high order bits of the last block to fill out the block size and I need advice on the "best way(tm)" to record the amount of padding while keeping it lazy a...
How do I pass position-independent parameters to scheme functions?
...
I really liked learning ML at college. I find functional programming often a refreshingly elegant way to write certain algorithms. I have heard of F# and played around with that a bit. Still, I've written some interesting functions in ML and would like to integrate them as libraries I could use in other applications.
Usually I paste ...
Basically I have this function:
private function clickURL(url:String):Function{
trace("Function has been instantiated");
return function(event:MouseEvent):void{
trace("Function has been run");
ExternalNavigation.newBrowserWindow(url);
}
}
The purpose of this function is to take an url, put the url in another fun...
I understand Ruby and Python's yield. What does Scala's yield do?
...
I'll probably best explain this through code. I got something like this:
var object1 = function(){
//do something
}
var object2 = function(){
//do something else
}
var objects = {
'o1' : object1,
'o2' : object2
};
var actions = [];
function addAction( actionName ){
var object = objects[actionName];
actions.push( functio...
How do I accept the following input?
(list of 0 or more charcters and ends with 3) or
(list of 1 or more characters 4 and 0 or more characters after 4)
something like
(match ( list 3)) -> #t
(match ( list 1 2 3)) -> #t
(match (list 1 2 3 4)) -> #t
(match (list 1 2 3 4 5)) -> #t
(match (list 4)) -> #f
EDIT: THIS IS NOT MY HO...
Are there any libraries written for Scala enabling Functional Reactive Programming?
...
I stumbled upon this question and i realized i forgot a lot of stuff from my nonprocedural programming class.
As I was trying to understand the code it seemed to me that it's terribly long-winded, so i attempted to shorten it. Does this do the same thing that the original code does?
merge([X|Xs], Ys) -> [X | merge(Ys, Xs)];
merge([], [...
I've recently been looking at functional programming with Javascript, to which I'm a noob.
While writing some 'map', 'reduce' and 'find' functions I discover that as of JS version 1.5 these functions are already available (see https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array)
I am however confused a...
What should 'foo' be called, given the following?
x.items is a set, y.values is a set.
function a(key) returns an ordered list of x.items
function b(x.item) returns a single y.value
Define foo(a, b), which returns a function, d, such that d(key) returns a list of y.values defined by: map(b, a(key)).
This feels like a fairly common a...
I am facing a couple of problems while writing an auto-memoizer in Scheme.
I have a working memoizer function, which creats a hash table and checks if the value is already computed. If it has been computed before then it returns the value else it calls the function.
(define (memoizer fun)
(let ((a-table (make-hash)))
(λ(n)
...