Fawers

Untitled

Jul 9th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. # It'd be great if the following:
  2.  
  3. map({|x| x**2}, [1,2,3])
  4.  
  5. # would compile to the following:
  6.  
  7. def __anon_func__(x):
  8.     return x**2
  9. map(__anon_func__, [1,2,3])
  10. del __anon_func__
  11.  
  12. # I know it looks Ruby-ish, but it would look
  13. # so much better. It would also let programmers
  14. # write anonymous functions with 2+ lines, which
  15. # would be awesome.
  16. #
  17. # Alternatives to {|x| x**2} could be:
  18. #
  19. # (\x -> x**2)
  20. # ((x) -> x**2)
  21. # ((x) => x**2)
  22. #
  23. # I think I just miss a good lambda support
  24. # on Python... :(
Advertisement
Add Comment
Please, Sign In to add comment