If you've bought into the functional programming paradigm, the chances are that you like both Erlang and Haskell. Both have purely functional cores and other goodness such as lightweight threads that make them a good fit for a multicore world. But there are some differences too.
Erlang is a commercially proven fault-tolerant language ...
I don't know much about functional programming but am interested in learning Clojure.
Are there any functional languages that would be a good point of reference to understand how functional programming works in Clojure?
Or is Clojure different enough in its functional programming approach that I would be better off to just focus on C...
I'm looking into LINQ and the query language appears (at least on the surface) to be nothing more than an implementation of map and/or list comprehensions as found in Haskell and other FP languages (particularly the generalisation of 'map' and 'for' in Scala). Is this correct? Is there more to the syntax than this? From the breathless to...
To my knowledge, combined with the knowledge of others, among the mainstream languages
Objective C
C#
VB.net
Java
Python
Ruby
Javascript
Lisp
Perl
have closures and anonymous functions. Plain C/C++ doesn't have either of those.
Do closures in these languages have the same semantics? How important are they for everyday programming?
...
I'm solving algorithmical problems, and i want to write custom functions and predicates that can be applied to collections. Recently, i started using Google Collections and it is just wonderful for this task.
I want to use BigInteger and BigDecimal same way, as i would use any other numbers. Without pondering how it should be done, i d...
I'm working on a library for Python that implements some persistent data structures (mainly as a learning exercise). However, I'm beginning to learn that explaining persistent data structures to people unfamiliar with them can be difficult. Can someone help me think of an easy (or at least the least complicated) way to describe persist...
I have only used 3 functional languages -- scala, erlang, and haskell, but in all 3 of these, the correct way to build lists is to prepend the new data to the front and then reversing it instead of just appending to the end. Of course, you could append to the lists, but that results in an entirely new list being constructed.
Why is this...
Hi,
I am attempting to make an algorithm to solve question 255 at Project Euler
I came up with this solution:
roundedSq n | (roundedSq n) == roundedSq (n-1) = n : roundedSq (n+1)
| rem n 2 == 1 = n : floor ( ((2*10^((d-1) `div` 2)) + ceiling (n `div` (2*10^((d-1) `div` 2)) )) `div` 2 )
| otherwise = n : floor ( ((7*10^...
This question is of course inspired by Monads in Haskell.
...
A classic programming exercise is to write a Lisp/Scheme interpreter in Lisp/Scheme. The power of the full language can be leveraged to produce an interpreter for a subset of the language.
Is there a similar exercise for Haskell? I'd like to implement a subset of Haskell using Haskell as the engine. Of course it can be done, but are the...
I'm aware that fold-left produces left-leaning trees and fold-right produces right-leaning trees, but when I reach for a fold, I sometimes find myself getting bogged down in headache-inducing thought trying to determine which kind of fold is appropriate. I usually end up unwinding the entire problem and stepping through the implementati...
I'm trying to call a 2 parameters function in List.foreach, with the first parameter fixed for a loop. In fact I want to curry a function of two parameters into a function of one parameter which returns a function of one parameter (as List.foldLeft do)
This does not work:
private def mathFunc1(a: Double, b: Double) =
println(a + b)...
To begin with, I'm virtually sold on the 'whole functional language thing'. It occurs to me that, for years, I've been doing mostly functional-style programming in Java. But I'm a bit loss as to how to start a large functional app. I'd like to see the source and build structure of a large project (OSS or whatever) so that I can see ho...
How do I get the function value f of an instance method?
class X(i : Int){
def method(y : Int) = y + i
}
val x = new X(10)
val f : (Int) => Int = ?
val r = x.method(2)
val r2 = f(2)
Calling x.method(2) and f(2) would be the same method call.
...
Here we have a function definition:
let f x = x + 3;;
Here is an expression:
let g = 4;;
Could g just be thought of as constant function that takes no arguments? Is there any difference?
...
Many modern programming languages allow us to handle potentially infinite lists and to perform certain operations on them.
Example [Python]:
EvenSquareNumbers = ( x * x for x in naturals() if x mod 2 == 0 )
Such lists can exist because only elements that are actually required are computed. (Lazy evaluation)
I just wondered out of in...
I am familiar with Common Lisp and trying to learn some Scheme, so I have been trying to understand how I'd use Scheme for things I usually code in Common Lisp.
In Common Lisp there's fboundp, which tells me if a symbol (the value of a variable) is bound to a function. So, I would do this:
(let ((s (read)))
(if (fboundp s)
(app...
In F#, use of the the pipe-forward operator (|>) is pretty common. However, in Haskell I've only ever seen function composition (.) being used. I understand that they are related, but is there a language reason that pipe-forward isn't used in Haskell or is it something else?
...
What are some of the criticisms leveled against exposing continuations as first class objects?
I feel that it is good to have first class continuations. It allow complete control over the execution flow of instructions. Advanced programmers can develop intuitive solutions to certain kind of problems. For instance, continuations are used...
I have been using f# and Haskell to learn functional programming for a while now. Until I can get f# approved at our company I must still use c#. I am still trying however to stay in the functional style as I have noticed several benefits.
Here is a typical problem.
There is a key-set table in the
database with 3 keys (6.5 million
row...