Hi,
I'm looking for a clean, idiomatic way to do a "backwards reduce" in Clojure.
I've got
(def fns '(fn1 fn2 fn3))
(def val 42)
I'd like to obtain (fn3 (fn2 (fn1 val))), and I'm not picky about the order. So I'd like to consecutively apply a sequence of functions to a value, rather than consecutively a sequence of values to a fu...
The problem:
I have a legacy php app that is coded in no particular style (some OO, function libraries, some templates, no templates), which I am slowly rewriting, cleaning up, and adding to.
When I introduced templates to the system, it was immediately evident that that would really clean up and simplify the code a lot because of th...
I have have read several entries regarding dropping several functional functions from future python, including map and reduce.
What is the official policy regarding functional extensions?
is lambda function going to stay?
...
What is the best way to do the following in Python:
for item in [ x.attr for x in some_list ]:
do_something_with(item)
This may be a nub question, but isn't the list comprehension generating a new list that we don't need and just taking up memory? Wouldn't it be better if we could make an iterator-like list comprehension.
...
Hi all,
I am trying to learn MVC in detail, and I am wondering whats the exact functional flow internally, in the sense of which functions(important functions) are called and what they does when the application starts and which function are called apart from the controller actions that we write in our application as we proceed.
Help in...
Which one of these do you prefer?
foreach(var zombie in zombies)
{
zombie.ShuffleTowardsSurvivors();
zombie.EatNearbyBrains();
}
or
zombies.Each(zombie => {
zombie.ShuffleTowardsSurvivors();
zombie.EatNearbyBrains();
});
...
I'm trying to write my own "functional" little lib in Java. If I have this function :
public static <T> List<T> filter(Iterable<T> source,BooleanTest predicate)
{
List<T> results = new ArrayList<T>();
for(T t : source)
{
if(predicate.ok(t))
results.add(t);
}
return results;
}
why can't I use it...
While reading "The Seasoned Schemer" I've begun to learn about letrec. I understand what it does (can be duplicated with a Y-Combinator) but the book is using it in lieu of recurring on the already defined function operating on arguments that remain static.
An example of an old function using the defined function recurring on itself (no...
Let's say I have a method expecting another method as a parameter. Is it possible to send an object's instance methods for that parameter? How would I handle methods that have no parameters?
I'll write some pseudocode:
void myMethod1(callback<void,int> otherFunc); // imagine a function returning void, and taking a int parameter
void m...
I have a f function with signature f :: [a] -> StateT Int Reader b [c], and f' with signature f' :: a -> StateT Int Reader b [c]
The computation in f (very simplified) looks like that:
f [] = return []
f (s:st) = f' s >>= \x ->
f st >>= \y ->
return $ ...
And in place of the ... I would like to return the [c] pa...
Hi,
I was trying to 'extend' a closed class
collections.defaultdict(lambda: 1)
by addint it 2 methods, called 'vocabulary', and 'wordcount'
apparently it's impossible to setattr method to builin types, nor can I inherit from defaultdic, so I decided to write a class and redirect calls to it to the type I want to extend.
class BagOfW...
hi
I want to call member function by passing it as template parameter, without using boost is possible. Here is an example off what I tried to do,
class object { void method(); }
{
object object_instance;
...
apply<object:: method>();
...
template<class F>
void apply() { F(object_instance); } // want to call object_instance.F()
}
t...
I have just started using Scala and wish to better understand the functional approach to problem solving.
I have pairs of strings the first has placeholders for parameter and it's pair has the values to substitute. e.g.
"select col1 from tab1 where id > $1 and name like $2"
"parameters: $1 = '250', $2 = 'some%'"
There may be many more t...
This is a follow-up now that Scala 2.8.0 beta is out to this question:
http://stackoverflow.com/questions/1710813/what-is-a-proper-way-to-manage-flexible-typed-immutable-data-structures-in-scal
The new technique is to copy a case class, e.g.
case class Person(name:String, email:String)
val bob = Person("Bob", "[email protected]")
val jill = ...
hello
I finally started learning functional languages (emacs lisp) and it makes explicit distinction between functions and special forms such as flow control , for example if.
Is there a fundamental/theoretical reason why special forms are distinct from functions? do any languages provide functional if?
Thanks
...
hi.
I am currently dabbling in expert systems, emacs lisp, and reading up about artificial intelligence. Traditionally, artificial intelligence is associated with LISP and expert systems with CLIPS. However, I have noticed in computational sciences how much Python is being used. What about the area of artificial intelligence and mach...
Hi,
I'm working on my first project using an external supplier, who will develop some web services for the company I work for.
My question is - at what stage of the project lifecycle would you expect the WDSL (and any associated Schemas) to be delivered?
Personally, I think it's a service contract, so I wouldn't expect it to be unre...
I've caught the functional programming bug, so naturally nothing is good enough for me anymore. ;)
So, in bash one could write:
case $status in
"foo") status="bar" ;;
"baz") status="buh" ;;
*) status=$status ;;
esac
but I'm afraid of typos, so I'd prefer to write:
status=case $status in
"foo") "bar" ;;
"baz") "buh" ;;
*...
Hi can someone tell me some good tutorials on fold left and map
...
I have a function specification that states it that should evaluate a polynomial function of one variable. The coefficient of the function is given as a list. It also accepts the value of the variable as a real.
For example: eval(2, [4, 3, 2, 1]) = 26 (1*x^3 + 2*x^2 + 3*x^1 + 4*x^0, where x = 2)
Here's the function in python, but I'...