Progress bar. Code to run:
from terminal_easy import *
from asyncio import sleep as async_sleep
async def main():
for _ in range(100):
update_progress(1)
await async_sleep(0.01)
progress(Progress bar. Code to run:
from terminal_easy import *
from asyncio import sleep as async_sleep
async def main():
for _ in range(100):
update_progress(1)
await async_sleep(0.01)
progress(If you've been trying to get into functional programming, there's a good chance you've heard of composition and piping. These concepts apply to point-free programming. This is an attempt at a simple, clear explanation of function composition and piping. I will write these examples in F#, but the concepts apply to other languages like Haskell. They just use different operators sometimes.
Prerequisites: basic programming knowledge. This explanation is going to be simple.
Piping
Let's begin with the simpler of the two (at least according to my experience): piping. There are two ways which you could
pipe a value to a function. Forwards, and backwards. When you pipe forward, you are applying the left side of the forward
| defmodule Lexer do | |
| def lex(current \\ 0, tokenstream \\ [], len, input_str) do | |
| char = String.at(input_str, current) | |
| unless current >= len do | |
| cond do | |
| ... | |
| end | |
| else | |
| tokenstream | |
| end |