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
| μ> "hi".send :method_missing, :M | |
| NoMethodError: undefined method `M' for "hi":String | |
| from (irb):11 | |
| from /usr/bin/irb:12:in `<main>' | |
| μ> "hi".method_missing | |
| NoMethodError: private method `method_missing' called for "hi":String | |
| from (irb):12 | |
| from /usr/bin/irb:12:in `<main>' | |
| μ> "hi".send :method_missing, :M | |
| NoMethodError: private method `M' called for "hi":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
| (define (make-queue) | |
| (let ([front-ptr '()] | |
| [rear-ptr '()]) | |
| (define (dispatch m) | |
| (cond ([eq? m 'empty-queue?] | |
| (null? front-ptr)) | |
| ([eq? m 'front-queue] | |
| (if (null? front-ptr) | |
| (error "FRONT called with an empty queue") | |
| (mcar front-ptr))) |
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
| data Silly a = Silly (Silly a -> a) | |
| herp :: Silly a -> a | |
| herp (Silly f) = f (Silly f) | |
| derp :: a | |
| derp = herp (Silly herp) |
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 svnie import * | |
| sl = Layout("/tmp/svnie.XfW7tz", | |
| [ Directory("scripts", | |
| [ File("build.sh", "#!/bin/bash\necho build\n") | |
| , File("release.sh", "#!/bin/bash\necho release\n") | |
| ]) | |
| , Directory("sources", | |
| [ File("main.cpp", "int main(){ return 0 }\n") | |
| ]) |
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
| def f(a, b, c): | |
| return a ** (b ** c) | |
| def g(a, b): | |
| return (b, a) | |
| >>> f(2, *g(2,3)) | |
| 512 | |
| >>> f(2, *g(3,2)) | |
| 256 |
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
| #lang racket | |
| (require "hw4.rkt") | |
| ;; Tests Start Here | |
| ; These definitions will work only after you do some of the problems | |
| ; so you need to comment them out until you are ready. | |
| ; Add more tests as appropriate, of course. |
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 ViewPatterns #-} | |
| module Main where | |
| import Control.Applicative | |
| import Control.Concurrent | |
| import Control.Concurrent.Async | |
| import Data.List (delete) | |
| import System.Environment (getArgs) | |
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
| val t1 = only_capitals [] = [] | |
| val t2 = only_capitals ["hello", "bye"] = [] | |
| val t3 = only_capitals ["Anal", "hello", "bye"] = ["Anal"] | |
| val t4 = only_capitals ["hello", "Pemis", "bye"] = ["Pemis"] | |
| val t5 = only_capitals ["hello", "bye", "Eblo"] = ["Eblo"] | |
| val t6 = longest_string1 [] = "" | |
| val t7 = longest_string1 ["pemis"] = "pemis" | |
| val t8 = longest_string1 ["pemis", "hello"] = "pemis" | |
| val t9 = longest_string1 ["eblo", "hello"] = "hello" |
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 os import popen | |
| def f(xs): | |
| return eval(popen("""ghc -ignore-dot-ghci -e "sequence %s" """ % xs).read()) |
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 Main where | |
| import Control.Monad (guard) | |
| import Data.Array (Ix) | |
| main :: IO () | |
| main = do | |
| print . sum . head $ solve 3 example1 -- at least one solution exists |