Here's a puzzle: define some higher-order function f such that, using only f and parentheses, you can define the three higher-order functions const, id and bothOn.
Those three functions could be defined in a straightforward way and in the Haskell programming language as follows:
-- takes two arguments, ignores the second and returning ...
I have a list of dates and values in the format:
{{{dateInfo1},value1},{{dateInfo2},value2},...,{{dateInfoN},valueN}}
With some actual dates and values:
{{{1971, 1, 31, 0, 0, 0.}, 1.0118}, {{1971, 2, 28, 0, 0, 0}, 1.0075},
..., {{2010, 5, 31, 0, 0, 0.}, 1.0403}}
For those curious, it's a list of US versus CAD $ values pulled from...
What are my options in terms of a fast functional language for library use in a cross-platform Qt C++ application?
It seems almost all languages (functional or not) have some way of calling C/C++ code in an easy manner. I'd like to go the other way around - write an application in Qt using C++ for stateful business logic, GUIs and stuf...
update
Since one effect of these functions is to provide a way to use method chaining on methods that would not normally support it *, I'm considering calling them chain and copychain, respectively. This seems less than ideal though, since the would-be copychain is arguably a more fundamental concept, at least in terms of functional pr...
Hi,
I know, I might be asking much, but does any one know of some nice little programming examples / libraries for Haskell.
For a 'introduction to programming' course I want to show that Haskell is more than a 'little script language to sort numbers'.
I already found a Quake clone (Real world Haskell programming) which is impressiv...
After touching on Monads in respect to functional programming, does the feature actually make a language pure, or is it just another "get out of jail free card" for reasoning of computer systems in the real world, outside of blackboard maths?
EDIT:
This is not flame bait as someone as said in this post, but a genuine question that I a...
Hello, I'm having a problem in fixing a warning that OCaml compiler gives to me.
Basically I'm parsing an expression that can be composed by Bool, Int and Float.
I have a symbol table that tracks all the symbols declared with their type:
type ast_type = Bool | Int | Float
and variables = (string, int*ast_type) Hashtbl.t;
where int i...
What is the killer benefit of Reactive Extensions (for either .NET or JavaScript)? Why should a developer learn and use them?
...
Hi, I am a C# developer and these days I am trying to learn Haskell from the online book Real World Haskell. From what I have learnt so far, I am quite impressed with the language. However coming from OO side of the world, I always start with thinking in terms of interfaces, classes and type hierarchies. Because of lack of OO in Haskell,...
Haskell is generally referenced as an example of a purely functional language. How can this be justified given the existence of System.IO.Unsafe.unsafePerformIO ?
Edit: I thought with "purely functional" it was meant that it is impossible to introduce impure code into the functional part of the program.
...
If you were designing a programming language that features automatic memory management, would using reference counting allow for determinism guarantees that are not possible with a garbage collector?
Would there be a different answer to this question for functional vs. imperative languages?
...
Is it possible to implement Haskell typeclasses in C++? If yes, then how?
...
Good morning,
I have been developing for a few months in R and I have to make sure that the execution time of my code is not too long because I analyze big datasets.
Hence, I have been trying to use as much vectorized functions as possible.
However, I am still wondering something.
What is costly in R is not the loop itself right?
I m...
Hi,
I have been doing some functional programming and had a question. Perhaps I might be missing something but is there any way to stop a "reduce()" function midway? Lets say when I reach a certain condition? The idea somehow seems anti functional. I haven't seen any such option in python or F#,
As an example, lets say I have a list s...
Which are the uses for id function in Haskell?
...
I've noticed while on my quest to lean functional programming that there are cases when parameter lists start to become excessive when using nested immutable data structures. This is because when making an update to an object state, you need to update all the parent nodes in the data structure as well. Note that here I take "update" to m...
I'm streaming a very large collection through a script and am currently using ifilter in a simple call to reject certain values, i.e.:
ifilter(lambda x: x in accept_list, read_records(filename))
That's one predicate, but now it's occurred to me I should add another, and I might want to add others in the future. The straightforward way...
Given an array containing other nested arrays, I want to create an array containing only the elements from the first array. For example [["1", "2"], "3", [["4"]]] should evaluate to ["1", "2", "3", "4"].
I've managed to make a method that works:
@@unwrapped_array = []
def unwrap_nested_array(array)
if array.respond_to?('each')
...
I have been learning about various functional languages for some time now including Haskell, Scala and Clojure. Haskell has a very strict and well-defined static type system. Scala is also statically typed. Clojure on the other hand, is dynamically typed.
So my questions are
What role does the type system play in a functional language...
OK, I understand pretty well how to use both function and macros.
What I'm curious about is why the compiler can't be a bit more clever when integrating the two, e.g. consider the Clojure code:
(defmacro wonky-add [a b] `(+ ~a (* 2 ~b)))
(defn wonky-increment [a] (apply wonky-add a 1))
=> Error: can't take value of a macro
Yes, I kn...