[package] [Java implementation] [Execution output]


HashSet


import java.util.function.Function;

import church.lang.Array;

import church.util.HashTable;
import church.util.CollectionsSupport;
import church.util.LinkedList;

class HashSet<T>: hashSet1(HashTable<T, T>: hashTable); // todo needs a different name from below :(

set(elements) = hashSet1(HashTable.hashTable4(Function.identity(), ==, hashCode, elements));

empty_set = set([]);

// size HashSet: set = set.hashTable.size; // equivalent to the 'OO' style below
(HashSet: set).size = set.hashTable.size; // the parentheses are optional

(HashSet: set).contains(element) = set.hashTable.contains(element); // all the parentheses are optional

leftFold  = CollectionsSupport.leftLift (HashTable.leftFold,  (HashSet: s) −> s.hashTable);
rightFold = CollectionsSupport.rightLift(HashTable.rightFold, (HashSet: s) −> s.hashTable);

stream << hashSet = CollectionsSupport.encode3(stream, leftFold, hashSet, <<);