Files
30-seconds-of-code/snippets/delay.md
Angelos Chalaris 0f36c17995 Update explanations
Update explanation in digitize
Update explanation in delay
Update explanation in curry
Update explanation in compose_right
Update explanation in compose
2020-01-03 13:08:00 +02:00

25 lines
397 B
Markdown

---
title: delay
tags: function,intermediate
---
Invokes the provided function after `ms` milliseconds.
Use `time.sleep()` to delay the execution of `fn` by `ms / 1000` seconds.
```py
from time import sleep
def delay(fn, ms, *args):
sleep(ms / 1000)
return fn(*args)
```
```py
delay(
lambda x: print(x),
1000,
'later'
) # prints 'later' after one second
```