This file contains hidden or 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
from collections import defaultdict | |
class Memory: | |
MEMORY = {0: None} | |
@staticmethod | |
def allocate(value): | |
address = max(Memory.MEMORY.keys()) + 1 | |
Memory.MEMORY[address] = value |
This file contains hidden or 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
// Provided by Andrew Gibson @gooballLogic | |
// Set up: | |
// - dotnet new console | |
// - dotnet add package OneOf | |
// Implement each of the methods below so that they all compile | |
// There only one valid implementation for each function (apart from f5 & f6) | |
using OneOf; |
This file contains hidden or 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 LightBulb | |
( LightBulb | |
, newLightBulb | |
, switchOn | |
, switchOff | |
) where | |
import Control.Concurrent (Chan, newChan, readChan, writeChan) | |
import Control.Concurrent.Async (async) | |
import Control.Monad.Loops (iterateM_) |
This file contains hidden or 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 LogParser exposing (..) | |
import Parser exposing (..) | |
type LogPart | |
= Text String | |
| URL String | |
This file contains hidden or 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
--command "stack ghci project:lib project:test:project-test --ghci-options='-fobject-code -Werror -Wall'" -T=main |
This file contains hidden or 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 GeneralisedNewtypeDeriving #-} | |
{-# LANGUAGE LambdaCase #-} | |
module BowlingSpec where | |
import Test.Hspec | |
import Control.Applicative ((<|>)) | |
newtype Frame = Frame Int deriving (Num, Enum) |
This file contains hidden or 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
const FRAMES_IN_GAME: i32 = 10; | |
const PINS_IN_FRAME: i32 = 10; | |
const ROLLS_IN_FRAME: usize = 2; | |
const ROLLS_IN_STRIKE_FRAME: usize = 1; | |
const ROLLS_IN_SCORE_DEFAULT: usize = 2; | |
const ROLLS_IN_SCORE_SPARE: usize = 3; | |
const ROLLS_IN_SCORE_STRIKE: usize = 3; | |
struct Game { | |
scores: Vec<i32>, |
This file contains hidden or 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
type LoadedContent a | |
= Loading | |
| Success a | |
| Failure | |
type alias Model | |
= LoadedContent Logs | |
This file contains hidden or 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 ApplicativeDo #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE UnicodeSyntax #-} | |
module Main where | |
import Control.Lens | |
import Control.Monad ((>=>)) |
This file contains hidden or 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 InstanceSigs #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE GADTs #-} | |
import Control.Monad ((>=>)) | |
{- | |
-- Initial style | |
data Console a = GetLine String (String -> Console a) |
NewerOlder