Skip to content

Instantly share code, notes, and snippets.

View Jeffrey04's full-sized avatar
🏳️‍🌈
Learning rust

Choon-Siang Lai Jeffrey04

🏳️‍🌈
Learning rust
View GitHub Profile
import time
import json
import requests
from lxml.html import fromstring
def pokemon_get_type(tree):
result = []
for _type in tree.cssselect('.itype'):
@Jeffrey04
Jeffrey04 / lib.rs
Created August 29, 2018 07:21
Implementing Simple Linked List @ Exercism
pub struct SimpleLinkedList<T> {
head: Option<Box<Node<T>>>,
}
pub struct Node<T> {
data: T,
next: Option<Box<Node<T>>>,
}
impl<T> SimpleLinkedList<T> {
pub trait Functor<F, V> {
fn fmap(self, func: F) -> V;
}
pub trait Monad<F, U> {
fn bind(self, func: F) -> U;
}
pub trait Applicative<F, U> {
fn lift(self, func: F) -> U;
### Keybase proof
I hereby claim:
* I am jeffrey04 on github.
* I am jeffrey04 (https://keybase.io/jeffrey04) on keybase.
* I have a public key ASC07wQXJaYSGGd_4z8fMKdJLRkWl8-kMoK59_N7U_D9Kwo
To claim this, I am signing this object:
@Jeffrey04
Jeffrey04 / gist:9c21877f54f6b9540ddc3412e5d1137e
Last active May 25, 2017 07:56
Category Theory Note dump

Terms

morphism = function = arrow category: objects and arrows source = origin of arrow target = destination of arrow

haskell

f :: A -> B

@Jeffrey04
Jeffrey04 / count_digits.php
Created December 4, 2012 09:09
Count the number of digits of a number
#!/usr/bin/env php
<?php
function count_digits($number, $base = 10) {
return get_n(
$base,
intval(is_string($number) ? strval($number) : $number, $base)
);
}