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
{-# LANGUAGE DeriveFunctor, TypeFamilies #-} | |
module Main where | |
data Pair a = Pair a a | |
deriving (Eq) | |
getFst :: Pair a -> a | |
getFst (Pair x1 _) = x1 |
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
{-# LANGUAGE DeriveFunctor, TypeFamilies #-} | |
module Main where | |
data Pair a = Pair a a | |
deriving (Eq) | |
getFst :: Pair a -> a | |
getFst (Pair x1 _) = x1 |
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
#lang racket | |
(define the-key 'the-key) | |
(define the-spell-book 'the-spell-book) | |
(define person% | |
(class object% | |
(init-field items h) | |
(super-new) | |
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
#lang racket | |
(provide (except-out (all-defined-out) | |
stack)) | |
(struct exn:fail:stack exn:fail ()) | |
(struct stack ([vector] | |
[top #:mutable]) | |
#:transparent) |
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 PCP where | |
import Data.List | |
import Data.Tree | |
-- breadth-first traversal | |
levelf :: Forest a -> [[a]] | |
levelf = unfoldr f | |
where f [] = Nothing | |
f xs = Just (map rootLabel xs, concat $ map subForest xs) |
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 Crush( | |
AST(..) | |
, crush | |
, crushMap | |
, crushMapM | |
-- debugging | |
, buildAst | |
, printAst | |
) 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 Bridge where | |
import Data.List | |
import Data.Maybe | |
import qualified Data.Tree as DTree | |
import qualified Data.Map as Map | |
-- Note that user must ensure there is at least one (0, x) in pieces | |
pieces :: [Piece] | |
pieces = [(0,2), (2,2), (2,3), (3,4), (3,5), (0,1), (10,1), (9,10)] |
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
;guile 2.2.3 | |
(use-modules (ice-9 local-eval)) | |
(use-modules (ice-9 match)) | |
(use-modules (srfi srfi-9)) | |
(define-record-type Just | |
(make-Just x) | |
Just? | |
(x Just-x)) | |
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
{-# LANGUAGE DeriveFunctor #-} | |
module Crush( | |
AST(..) | |
, crush | |
, crushMap | |
, crushMapM | |
-- debugging | |
, buildAst | |
, printAst |
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
#lang racket/base | |
(provide uniq) | |
;;; | |
;;; Uniq | |
;;; | |
; The function uniq takes a list as input and returns a new list: | |
; adjacent elements are compared and omits any repeated elements. | |
; In other words, uniq works like the Unix utility uniq, but on list. |
OlderNewer