If you’re interested in my Python patch verification system project (or want to get interested :-), check out notes on system architecture I just added. Feel free to comment here or on the wiki, I’d love to hear your feedback.
Minor annoyance
19 05 2007Map operation on sets isn’t closed, both in Python:
>>> type( map(lambda x: x**2, set([1,2,3,4])) )
<type 'list'>
and Ruby:
>> Set.new([1,2,3,4]).map { |x| x**2 }.class
=> Array
At least Haskell does the right thing:
Main> typeOf( Set.map (\x -> x^2) (Set.fromList([1,2,3,4::Integer])) )
Set Integer
An obvious workaround is to operate on lists and convert to sets once you need them. You have to ask yourself whether it will cause performance problems in your application.
Comments : 5 Comments »
Categories : haskell, python, ruby