Skip to content

Instantly share code, notes, and snippets.

View mperry's full-sized avatar

Mark Perry mperry

View GitHub Profile
@mperry
mperry / bugImplicitBoxing.groovy
Last active August 29, 2015 13:59
Implicit boxing with the extension module does not seem to work with Groovy 2.2.0, ok with 2.2.2
@GrabResolver('https://oss.sonatype.org/content/repositories/snapshots/')
@Grab('com.github.mperry:functionalgroovy-main:0.5-SNAPSHOT')
import groovy.transform.TypeChecked
import org.junit.Test
import static junit.framework.Assert.assertTrue
@TypeChecked
class StreamTest {
@mperry
mperry / jvm.bat
Last active August 29, 2015 13:58
Switches java versions and add the new JAVA_HOME to the front of the PATH.
@echo off
set VERSION=%1
call setEnvVar JAVA_HOME JAVA%VERSION%_HOME
echo JAVA_HOME=%JAVA_HOME%
@mperry
mperry / IdTest.java
Last active August 29, 2015 13:58
Exploring equals and hash code for Java 8 Lamdas
package com.github.mperry;
import org.junit.Test;
import java.util.function.Function;
import static org.junit.Assert.assertTrue;
/**
* Created by MarkPerry on 3/04/2014.
@mperry
mperry / gist:8534788
Created January 21, 2014 05:15
This is an attempt to explore the duality of fold and unfold
Haskell definitions:
unfoldr :: (b -> Maybe (a, b)) -> b -> [a]
foldr :: (a -> b -> b) -> b -> [a] -> b
If I reverse the arrows on unfoldr
dual(unfoldr) :: [a] -> (Maybe (a, b) -> b) -> b
I think I need to show the type isomorphism (a -> b -> b) -> b is equivalent to Maybe (a, b) -> b, which is equivalent to
(a -> b -> b) == Maybe(a, b)