Skip to content

Instantly share code, notes, and snippets.

View pe200012's full-sized avatar
πŸ“–
Chasing goodness~

pe200012

πŸ“–
Chasing goodness~
  • Science Tokyo
  • Japan
  • 23:45 (UTC +09:00)
  • X @pe200012
View GitHub Profile
@pe200012
pe200012 / adt.fnlm
Created October 31, 2025 05:49
Algebraic Datatype & Pattern Matching in Fennel
;; Macro to define algebraic data types
;; Usage:
;; (defdata Maybe
;; Nothing ; Nullary constructor (no arguments)
;; [Just val] ; N-ary constructor with positional fields
;; (Good a b c)) ; Record constructor with named fields
;;
;; This will create a local table `Maybe` with constructors:
;; Maybe.Nothing() ; Returns {:variant "Nothing"}
;; Maybe.Just(val) ; Returns {:variant "Just" :fields [val]}
Haskell 54 mins β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ– 96.0%
Text 2 mins β–Šβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 4.0%
@pe200012
pe200012 / MergeSort.agda
Created March 12, 2022 12:00 — forked from wenkokke/MergeSort.agda
An implementation of mergesort in Agda.
open import Level using (_βŠ”_)
open import Function using (_∘_)
open import Data.Vec using (Vec; []; _∷_; foldr)
open import Data.Nat using (β„•; zero; suc; _+_)
open import Data.Nat.Properties.Simple using (+-right-identity; +-suc)
open import Data.Sum using (_⊎_; inj₁; injβ‚‚)
open import Data.Product using (βˆƒ; _Γ—_; _,_; proj₁; projβ‚‚)
open import Data.Empty using (βŠ₯-elim)
open import Relation.Nullary using (Dec; yes; no; Β¬_)
open import Relation.Binary using (module DecTotalOrder; DecTotalOrder; Rel)
module Lib where
-- 4
-- >>> euler 10
-- | euler's totient function
--
-- euler's totient function is defined as the number of positive integers
-- less than or equal to n which are coprime to n.
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}