Why Every Language Needs Its Underscore

Embed Size (px)

DESCRIPTION

Slides for my PyCon and DevDay talk about the idea of Underscore spread onto other languages. Video (in russian) is available here http://www.youtube.com/watch?v=lGAC6ftYUS0#t=12100

Citation preview

  • 1. _

2. _? Underscore JavaScript, , . 3. funcy? funcy Python, ... 4. images = [] for url in urls: for attempt in range(TRIES): try: images.append(download_image(url)) break except HttpError: if attempt + 1 == TRIES: raise 5. http_retry = retry(TRIES, HttpError) harder_download = http_retry(download_image) images = map(harder_download, urls) 6. d = {} for k, v in request.items(): try: d[k] = int(v) except (TypeError, ValueError): d[k] = None 7. walk_values(silent(int), request) 8. prev = None is_ascending = True for x in seq: if prev and x >= seq: is_ascending = False break prev = x 9. is_ascending = all(l < r for l, r in pairwise(seq)) 10. 11. _ ... ... 12. images = [] for url in urls: for attempt in range(TRIES): try: images.append(download_image(url)) break except HttpError: if attempt + 1 == TRIES: raise 13. ? ( ) 14. images = [] for url in urls: for attempt in range(TRIES): try: images.append(download_image(url)) break except HttpError: if attempt + 1 == TRIES: raise 15. def retry(...): ... http_retry = retry(TRIES, HttpError) harder_download = http_retry(download_image) images = [] for url in urls: images.append(harder_download(url)) 16. def retry(...): ... http_retry = retry(TRIES, HttpError) harder_download = http_retry(download_image) images = map(harder_download, urls) 17. retry map ( , ) 18. _ ... 19. # d = {} for k, v in request.items(): try: d[k] = int(v) except (TypeError, ValueError): d[k] = None # walk_values(silent(int), request) 20. # walk_values(int, request) # {k: int(v) for k, v in request.items()} 21. # 3 walk_values(int, data) # 8 {k: int(v) for k, v in data.items()} 22. walk_values(int, data) # {k: int(v) for k, v in data.items()} 23. _ ... 24. # # -", " # - {k: int(v) for k, v in request.items()} # walk_values(int, request) 25. _ ... 26. is_ascending = all(l < r for l, r in pairwise(seq)) 27. is_ascending = all(l < r for l, r in pairwise(seq)) , . 28. _ 29. JavaScript Array, Function, Underscore, Lo-Dash Python itertools, functools, funcy, toolz, fn.py Ruby Enumerable, ActiveSupport PHP functional-php, Underscore.php Clojure clojure.core 30. Java FunctionalJava, lambdaj C# - LINQ Objective-C Underscore.m 31. _ 32. hackflow.comgithub.com/Suor@hackflow