__init__.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. apply,
  24. comp,
  25. complement,
  26. compose,
  27. compose_left,
  28. concat,
  29. concatv,
  30. count,
  31. curry,
  32. diff,
  33. first,
  34. flip,
  35. frequencies,
  36. identity,
  37. interleave,
  38. isdistinct,
  39. isiterable,
  40. juxt,
  41. last,
  42. memoize,
  43. merge_sorted,
  44. peek,
  45. pipe,
  46. second,
  47. thread_first,
  48. thread_last,
  49. )
  50. from .exceptions import merge, merge_with
  51. accumulate = toolz.curry(toolz.accumulate)
  52. assoc = toolz.curry(toolz.assoc)
  53. assoc_in = toolz.curry(toolz.assoc_in)
  54. cons = toolz.curry(toolz.cons)
  55. countby = toolz.curry(toolz.countby)
  56. dissoc = toolz.curry(toolz.dissoc)
  57. do = toolz.curry(toolz.do)
  58. drop = toolz.curry(toolz.drop)
  59. excepts = toolz.curry(toolz.excepts)
  60. filter = toolz.curry(toolz.filter)
  61. get = toolz.curry(toolz.get)
  62. get_in = toolz.curry(toolz.get_in)
  63. groupby = toolz.curry(toolz.groupby)
  64. interpose = toolz.curry(toolz.interpose)
  65. itemfilter = toolz.curry(toolz.itemfilter)
  66. itemmap = toolz.curry(toolz.itemmap)
  67. iterate = toolz.curry(toolz.iterate)
  68. join = toolz.curry(toolz.join)
  69. keyfilter = toolz.curry(toolz.keyfilter)
  70. keymap = toolz.curry(toolz.keymap)
  71. map = toolz.curry(toolz.map)
  72. mapcat = toolz.curry(toolz.mapcat)
  73. nth = toolz.curry(toolz.nth)
  74. partial = toolz.curry(toolz.partial)
  75. partition = toolz.curry(toolz.partition)
  76. partition_all = toolz.curry(toolz.partition_all)
  77. partitionby = toolz.curry(toolz.partitionby)
  78. peekn = toolz.curry(toolz.peekn)
  79. pluck = toolz.curry(toolz.pluck)
  80. random_sample = toolz.curry(toolz.random_sample)
  81. reduce = toolz.curry(toolz.reduce)
  82. reduceby = toolz.curry(toolz.reduceby)
  83. remove = toolz.curry(toolz.remove)
  84. sliding_window = toolz.curry(toolz.sliding_window)
  85. sorted = toolz.curry(toolz.sorted)
  86. tail = toolz.curry(toolz.tail)
  87. take = toolz.curry(toolz.take)
  88. take_nth = toolz.curry(toolz.take_nth)
  89. topk = toolz.curry(toolz.topk)
  90. unique = toolz.curry(toolz.unique)
  91. update_in = toolz.curry(toolz.update_in)
  92. valfilter = toolz.curry(toolz.valfilter)
  93. valmap = toolz.curry(toolz.valmap)
  94. del exceptions
  95. del toolz