__init__.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. """
  2. Alternate namespace for toolz such that all functions are curried
  3. Currying provides implicit partial evaluation of all functions
  4. Example:
  5. Get usually requires two arguments, an index and a collection
  6. >>> from toolz.curried import get
  7. >>> get(0, ('a', 'b'))
  8. 'a'
  9. When we use it in higher order functions we often want to pass a partially
  10. evaluated form
  11. >>> data = [(1, 2), (11, 22), (111, 222)]
  12. >>> list(map(lambda seq: get(0, seq), data))
  13. [1, 11, 111]
  14. The curried version allows simple expression of partial evaluation
  15. >>> list(map(get(0), data))
  16. [1, 11, 111]
  17. See Also:
  18. toolz.functoolz.curry
  19. """
  20. import toolz
  21. from . import operator
  22. from toolz import (
  23. comp,
  24. complement,
  25. compose,
  26. concat,
  27. concatv,
  28. count,
  29. curry,
  30. diff,
  31. dissoc,
  32. first,
  33. flip,
  34. frequencies,
  35. identity,
  36. interleave,
  37. isdistinct,
  38. isiterable,
  39. juxt,
  40. last,
  41. memoize,
  42. merge_sorted,
  43. peek,
  44. pipe,
  45. second,
  46. thread_first,
  47. thread_last,
  48. )
  49. from .exceptions import merge, merge_with
  50. accumulate = toolz.curry(toolz.accumulate)
  51. assoc = toolz.curry(toolz.assoc)
  52. assoc_in = toolz.curry(toolz.assoc_in)
  53. cons = toolz.curry(toolz.cons)
  54. countby = toolz.curry(toolz.countby)
  55. do = toolz.curry(toolz.do)
  56. drop = toolz.curry(toolz.drop)
  57. excepts = toolz.curry(toolz.excepts)
  58. filter = toolz.curry(toolz.filter)
  59. get = toolz.curry(toolz.get)
  60. get_in = toolz.curry(toolz.get_in)
  61. groupby = toolz.curry(toolz.groupby)
  62. interpose = toolz.curry(toolz.interpose)
  63. itemfilter = toolz.curry(toolz.itemfilter)
  64. itemmap = toolz.curry(toolz.itemmap)
  65. iterate = toolz.curry(toolz.iterate)
  66. join = toolz.curry(toolz.join)
  67. keyfilter = toolz.curry(toolz.keyfilter)
  68. keymap = toolz.curry(toolz.keymap)
  69. map = toolz.curry(toolz.map)
  70. mapcat = toolz.curry(toolz.mapcat)
  71. nth = toolz.curry(toolz.nth)
  72. partial = toolz.curry(toolz.partial)
  73. partition = toolz.curry(toolz.partition)
  74. partition_all = toolz.curry(toolz.partition_all)
  75. partitionby = toolz.curry(toolz.partitionby)
  76. pluck = toolz.curry(toolz.pluck)
  77. random_sample = toolz.curry(toolz.random_sample)
  78. reduce = toolz.curry(toolz.reduce)
  79. reduceby = toolz.curry(toolz.reduceby)
  80. remove = toolz.curry(toolz.remove)
  81. sliding_window = toolz.curry(toolz.sliding_window)
  82. sorted = toolz.curry(toolz.sorted)
  83. tail = toolz.curry(toolz.tail)
  84. take = toolz.curry(toolz.take)
  85. take_nth = toolz.curry(toolz.take_nth)
  86. topk = toolz.curry(toolz.topk)
  87. unique = toolz.curry(toolz.unique)
  88. update_in = toolz.curry(toolz.update_in)
  89. valfilter = toolz.curry(toolz.valfilter)
  90. valmap = toolz.curry(toolz.valmap)
  91. del exceptions
  92. del toolz