diff --git a/snippets/compose.md b/snippets/compose.md index 08f90736a..fff94ea65 100644 --- a/snippets/compose.md +++ b/snippets/compose.md @@ -5,7 +5,7 @@ tags: function,intermediate Performs right-to-left function composition. -Use `reduce()` to perform right-to-left function composition. +Use `functools.reduce()` to perform right-to-left function composition. The last (rightmost) function can accept one or more arguments; the remaining functions must be unary. ```py diff --git a/snippets/compose_right.md b/snippets/compose_right.md index 696f89da6..4ee634b94 100644 --- a/snippets/compose_right.md +++ b/snippets/compose_right.md @@ -5,7 +5,7 @@ tags: function,intermediate Performs left-to-right function composition. -Use `reduce()` to perform left-to-right function composition. +Use `functools.reduce()` to perform left-to-right function composition. The first (leftmost) function can accept one or more arguments; the remaining functions must be unary. ```py diff --git a/snippets/curry.md b/snippets/curry.md index 855cd81a6..4f9b5e7c0 100644 --- a/snippets/curry.md +++ b/snippets/curry.md @@ -5,7 +5,7 @@ tags: function,intermediate Curries a function. -Use `partial()` to return a new partial object which behaves like `fn` with the given arguments, `args`, partially applied. +Use `functools.partial()` to return a new partial object which behaves like `fn` with the given arguments, `args`, partially applied. ```py from functools import partial @@ -16,7 +16,7 @@ def curry(fn, *args): ```py add = lambda x, y: x + y -add10 = curry(sum, 10) +add10 = curry(add, 10) add10(20) # 30 ``` diff --git a/snippets/delay.md b/snippets/delay.md index d77d11683..499b32485 100644 --- a/snippets/delay.md +++ b/snippets/delay.md @@ -5,7 +5,7 @@ tags: function,intermediate Invokes the provided function after `ms` milliseconds. -Use `sleep()` to delay the execution of `fn` by `ms / 1000` seconds. +Use `time.sleep()` to delay the execution of `fn` by `ms / 1000` seconds. ```py from time import sleep diff --git a/snippets/digitize.md b/snippets/digitize.md index cc11f843c..74eb0c0d2 100644 --- a/snippets/digitize.md +++ b/snippets/digitize.md @@ -3,7 +3,7 @@ title: digitize tags: math,list,beginner --- -Converts a number to an array of digits. +Converts a number to a list of digits. Use `map()` combined with `int` on the string representation of `n` and return a list from the result.