Skip to content

Instantly share code, notes, and snippets.

View VideoCarp's full-sized avatar
🅱️
no status.

VideoCarp VideoCarp

🅱️
no status.
View GitHub Profile
@VideoCarp
VideoCarp / terminal_easy.md
Last active May 16, 2022 11:15
My python terminal module.

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(
@VideoCarp
VideoCarp / Function piping and composition.md
Created May 16, 2022 12:24
Function piping and composition

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

@VideoCarp
VideoCarp / lexer_function.ex
Last active May 24, 2022 00:55
Bits of code embedded onto my site.
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