0
votes
2answers
39 views

Python Applying map function to sub list

I have an array holding another object items : myarray=[] myarray.append((1,2,3)) myarray.append((4,5,6)) how can I apply a map function to the last 2 columns of the list somethign like def ...
2
votes
1answer
41 views

identifying gap size in 1D numpy array

I have a numpy array containing gaps of various sizes. I would like to fill the smaller gaps of size < N with linear interpolation. In other words for: N = 2 and x = np.array([10., 20., ...
1
vote
1answer
52 views

Is there any way to lazy evaluate function.func_name?

This question is not about my code I just want to claim the reason why I need lazy evalution on function.func_name I'm using a curry decorator in my code I made it to show curried arguments by ...
1
vote
2answers
77 views

Functional programming in Python: returning none instead of correct value [closed]

I wrote a functional code in python and I do not understand why it returns a None instead of the correct value which the code clearly generates. The purpose of this script is to take a ...
3
votes
1answer
61 views

Correct use of a fold or reduce function to long-to-wide data in python or javascript?

Trying to learn to think like a functional programmer a little more---I'd like to transform a data set with what I think is either a fold or a reduce operation. In R, I would think of this as a ...
4
votes
2answers
79 views

itertools or functools for find-replace list in python

I have a set of strings that are sometimes invalid that I'd like to replace with particular better strings. I've been playing with functools and itertools and would like to try applying these to the ...
2
votes
4answers
120 views

In Python, why can't an accumulator generators be written with lambdas? [closed]

Paul Graham describes the following problem: We want to write a function that generates accumulators-- a function that takes a number n, and returns a function that takes another number i and ...
4
votes
2answers
93 views

Python and functional language interop

My current primary programming language is python. There are lots of things I like about it, but I also like functional languages. Not enough to do an entire program in them, but definitely for ...
16
votes
2answers
299 views

How does this lambda/yield/generator comprehension work?

I was looking through my codebase today and found this: def optionsToArgs(options, separator='='): kvs = [ ( "%(option)s%(separator)s%(value)s" % {'option' : ...
0
votes
2answers
90 views

How can I define an operator (eg integrator) in Python operating on a multi-variable function?

How can I define an operator (eg integrator) in Python operating on a multi-variable function? My problem is that when I define an integrator function numint to numerically integrate a multivariable ...
3
votes
2answers
91 views

Using itertools for recursive function application

I need a Python function iterate(f, x) that creates an iterator returning the values x, f(x), f(f(x)), f(f(f(x))), etc (like, e.g., Clojure's iterate). First of all, I was wondering: Does this ...
0
votes
1answer
101 views

Partial and named arguments in Clojure

I'm a Python programmer just learning Clojure. In Python I love how I can used named arguments in a call to functools.partial: def pow(base, exponent): return base ** exponent exp = ...
0
votes
1answer
59 views

Python: Errno 57 when calling Server function in GUI

Question Why am I receiving error: [Errno 57] Socket is not connected, even though I have initialized the socket? The full code is on paste bin, but feel free to check out what I have provided here. ...
-3
votes
2answers
87 views

Understanding “def main” and “overloading” in Python [closed]

I often see some code with def main(A,B) some steps described as an "overloading for the main function", after reading something more specific about Python I know that this is not true because: ...
2
votes
4answers
77 views

Modify dict values inplace

I would like to apply a function to values of a dict inplace in the dict (like map in a functional programming setting). Let's say I have this dict: d = { 'a':2, 'b':3 } I want to apply the ...

1 2 3 4 5 16
15 30 50 per page