Skip to content

Instantly share code, notes, and snippets.

View caotic123's full-sized avatar

Tiago Campos caotic123

  • UFVJM - Universidade do Vale do Jequitinhonha e Mucuri.
  • Belo Horizonte - MG
  • X @Tiagocamposfer
View GitHub Profile
@luksamuk
luksamuk / escalona.apl
Created August 23, 2019 00:18
Escalonando Matrizes em APL: Código
∇R←IDENTITY N
R←(N N)⍴(1,N⍴0)
∇R←EXTENDBOTTOM MAT
R←(((↑⍴MAT)⍴1),0)\[1]MAT
∇R←EXTENDRIGHT MAT
R←(((2⌷⍴MAT)⍴1),0)\MAT
@enobayram
enobayram / maybe.c
Created May 21, 2017 15:57
Maybe monad in C
#include <stdlib.h>
#include <stdio.h>
// return :: Monad m => a -> m a
typedef void * /* m a */ return_t(void * /* a */);
// type kleisli_arrow a b = a -> m b
typedef void * /* m b */ kleisli_arrow(void * /* a */);
// bind :: Monad m => m a -> (a -> m b) -> m b
@rizo
rizo / monads.c++
Last active December 3, 2018 02:53
Quick and dirty demonstration of monads in C++.
#include <iostream>
#include <assert.h>
#include <forward_list>
#include <functional>
template <typename T>
struct option {
public:
class no_value { };
-- definition of Existential Type
data ∃ {A : Set} (B : A → Set) : Set where
_,_ : (x₁ : A) → B x₁ → ∃ \(x : A) → B x
-- left projection
p : {A : Set} {B : A → Set} → (∃ \(x : A) → B x) → A
p {A} {B} (a , b) = a
-- right projection
@machuidel
machuidel / option_type.h
Last active December 6, 2018 14:44
Option Type Macro
#pragma once
#ifndef _XOPTION_TYPE_H_
#define _XOPTION_TYPE_H_
#ifdef __cplusplus
extern "C"
{
#endif
@poizan42
poizan42 / inf-primes.v
Created November 27, 2014 20:08
Proof of the infinitude of primes
Require Import Coq.ZArith.ZArith.
Require Import Coq.ZArith.Znumtheory.
Require Import Coq.Sets.Ensembles.
Require Import Coq.Sets.Finite_sets.
Require Import Coq.PArith.BinPos.
Definition Z_ens := Ensemble Z.
Print Finite.
Print Empty_set.
Definition is_empty_set U A := forall x, ~(In U A x).
@Kimundi
Kimundi / java_rust_generic.md
Last active March 20, 2024 06:02
A light comparison between Rust and Java generics and type system features.

Introduction

If you are familiar with Java's generics, and are coming to Rust, you might be lead to assume that its generics are working the same way.

However, due to the different type systems, and different implementation details, there are quite a few differences between generic code in both languages.

This document tries to give a short summary about those differences:

Core functionality

Java

@splinterofchaos
splinterofchaos / monad-parser.cpp
Created November 19, 2012 17:32
Monadic parsing in C++
#include <memory>
#include <iostream>
#include <sstream>
#include <utility>
#include <algorithm>
#include <iterator>
struct sequence_tag {};
struct pointer_tag {};
@tarao
tarao / lambda.cpp
Created November 1, 2011 07:47
Lambda calculus with type inference in C++ template
namespace lambda {
////////////////////////////////////////////////
// Lambda term
namespace term {
template<char c> struct var {};
template<typename N, typename M> struct app {};
template<char v, typename M> struct abs {};