Skip to content

Instantly share code, notes, and snippets.

View Mercerenies's full-sized avatar

Silvio Mayolo Mercerenies

View GitHub Profile
@Mercerenies
Mercerenies / ziplist.agda
Created January 4, 2018 20:12
Proof of equivalence of two similar zip implementations
open import Agda.Builtin.Equality
record _∧_ (A B : Set) : Set where
constructor conj
field
proj₁ : A
proj₂ : B
data List (A : Set) : Set where
@Mercerenies
Mercerenies / nonemptytrans.hs
Created January 27, 2018 17:02
A monad transformer based on `NonEmptyT`
-- Note: The same warnings about ListT's poor behavior apply to this transformer.
-- https://wiki.haskell.org/ListT_done_right
import Data.List.NonEmpty
import Control.Monad
import Control.Monad.List
newtype NonEmptyT m a = NonEmptyT { unNonEmptyT :: m (NonEmpty a) }
import java.util.ArrayList;
import java.util.Collection;
public class CollRaw {
public static interface Test {
public StringBuilder append(Collection<?> value);
}
@Mercerenies
Mercerenies / assignment-profiling.lats
Last active June 11, 2018 21:20
Profiling of the various assignment-operator syntaxes in Latitude
;; manual
10000 times {
a := 1.
a= := { parent a := #'($1). }.
do { a = 2. }.
}.
;; assignable
@Mercerenies
Mercerenies / primes.hs
Created September 5, 2018 02:10
Count for the number of primes and semiprimes up to a given quantity
-- Haskell program which generates the table
import Data.Ratio
import Data.List
divides :: Integral a => a -> a -> Bool
divides y x = x `mod` y == 0
primeFactors :: Integral a => a -> [a]
primeFactors n | n < 1 = error "invalid input"
@Mercerenies
Mercerenies / custom_rules.xml
Created October 1, 2018 00:55
This configuration worked for me to compile Kotlin onto Android from the command line. My ant-fu is not great, but hopefully this helps someone else who struggled with it.
<?xml version="1.0" encoding="UTF-8"?>
<project name="kotlin_rules">
<property environment="env"/>
<typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${env.KOTLIN_HOME}/lib/kotlin-ant.jar"/>
<target name="-post-compile">
<path id="project.javac.classpath">
<path refid="project.all.jars.path" />
<path refid="tested.project.classpath" />
<path path="${java.compiler.classpath}" />
<path path="${project.target.android.jar}"/>
@Mercerenies
Mercerenies / silvertongue.pl
Last active January 16, 2019 05:30
Silver Tongue Forum Game Unspoken Rules
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
=pod
1. B<Don't use big words.> These people aren't very bright. Don't use words longer than 6 characters. Excludes punctuation.
%% -*- Prolog -*-
% A very simple "toothpicks" game in Prolog. Two players take turns
% drawing one, two, or three toothpicks from a stack. If you take the
% last one, then you lose. I made this late one night, mainly to prove
% to myself that game programming is actually possible in Prolog.
:-
use_module(library(readutil)).
<!DOCTYPE html>
<html>
<head>
<title>Math Stuff for Silly Internet Math Person</title>
<script type="application/javascript">
const WIDTH = 320;
#!/usr/bin/perl
# Insanity in WUAS.
use strict;
use warnings;
use 5.010;
use Data::Dumper;