This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.util.function.*; | |
import java.util.stream.*; | |
public class ParallelStreamTest { | |
static class IntGenerator implements Supplier<Integer> { | |
private int current = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FunctionRecord where | |
data FRecord = FRecord { | |
parent :: FRecord, | |
name :: String, | |
toString :: (FRecord -> String) | |
} | |
prototype = FRecord { parent = prototype, name = undefined, toString = (\r -> r.name) } | |
dierk = prototype.{ name = "Dierk" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------------------------------------------------------------------------ | |
-- ROSE TREES, FUNCTORS, MONOIDS, FOLDABLES, Frege version by Dierk Koenig | |
------------------------------------------------------------------------------------------------------------------------------ | |
module Lab6 where | |
import frege.prelude.Math(round, sin) | |
data Rose a = Rose a [Rose a] | |
derive Show Rose a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Countdown where | |
-- Countdown example from chapter 11 of Programming in Haskell, | |
-- Graham Hutton, Cambridge University Press, 2007. | |
-- Template for homework 10 in the FP101x course | |
-- Frege adaptions by Dierk Koenig | |
-- How Java's Date looks like through the Frege glasses | |
data Date = native java.util.Date where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Lab4 where | |
------------------------------------------------------------------------------------------------------------------------------ | |
-- RECURSIVE FUNCTIONS, Frege version by Dierk Koenig | |
------------------------------------------------------------------------------------------------------------------------------ | |
-- import frege.prelude.Math(pi) -- uncomment this when trying to use pi | |
-- =================================== | |
-- Ex. 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Functional parsing library from chapter 8 of Programming in Haskell, | |
-- Graham Hutton, Cambridge University Press, 2007. | |
-- Template file for the homework in the FP101x EdX course. | |
-- Read also: http://www.cs.nott.ac.uk/~gmh/monparsing.pdf | |
-- adapted to Frege by Dierk Koenig | |
-- uncomment code as needed | |
module Parsing where | |
import Data.Char |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.Function // requires Java 8 | |
class NullSafe<T> { | |
protected final T t | |
protected NullSafe(T t) {this.t = t} | |
static NullSafe<T> enter(T t) { new NullSafe<T>(t) } // enter or "return" is like a constructor | |
// in the general case, applicative would have the type Function<T, NullSafe<T>> but we don't need that here | |
NullSafe<T> rightShift (Function<T,T> applicative) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module realworld.experiments.ExampleTests where | |
test_that_is_expected_to_pass = 1 == 1 | |
test_that_is_expected_to_fail = 1 == 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@Grab('org.spockframework:spock-core:0.7-groovy-2.0') | |
import spock.lang.* | |
import java.lang.reflect.Field | |
class FregeSpec extends Specification { | |
@Shared Class testClass = realworld.experiments.ExampleTests | |
@Shared List<Field> testFields = testClass.fields.findAll { Field it -> it.modifiers == 25 && it.name.startsWith("test") } | |
@Unroll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// has all methods of List | |
trait ListLike { | |
@Delegate List linkedList = new LinkedList() | |
} | |
// stores anything but exposes only Strings | |
class StringList implements ListLike { | |
String get(int index) { linkedList.get(index).toString() } | |
} |