Skip to content

Instantly share code, notes, and snippets.

🏳️‍🌈
Learning rust

Choon-Siang Lai Jeffrey04

View GitHub Profile
@Jeffrey04
Jeffrey04 / lib.rs
Created Aug 29, 2018
Implementing Simple Linked List @ Exercism
View lib.rs
pub struct SimpleLinkedList<T> {
head: Option<Box<Node<T>>>,
}
pub struct Node<T> {
data: T,
next: Option<Box<Node<T>>>,
}
impl<T> SimpleLinkedList<T> {
View monad-redo.rs
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;
View gist:4db2e262c2b737c1d75f4641bf541a3e
### 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:
View gist:9c21877f54f6b9540ddc3412e5d1137e

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 Dec 4, 2012
Count the number of digits of a number
View count_digits.php
#!/usr/bin/env php
<?php
function count_digits($number, $base = 10) {
return get_n(
$base,
intval(is_string($number) ? strval($number) : $number, $base)
);
}
You can’t perform that action at this time.