Skip to content

Instantly share code, notes, and snippets.

View supki's full-sized avatar
🇸🇴
🤝 🏳️‍🌈

Matvey Aksenov supki

🇸🇴
🤝 🏳️‍🌈
  • Gorgoroth, Mordor
  • 04:08 (UTC)
View GitHub Profile
@supki
supki / pemis.rb
Created March 29, 2013 19:20
WAT
μ> "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
(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)))
@supki
supki / pemis.hs
Created March 20, 2013 19:31
Why contravariant type recursion is bad.
data Silly a = Silly (Silly a -> a)
herp :: Silly a -> a
herp (Silly f) = f (Silly f)
derp :: a
derp = herp (Silly herp)
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")
])
@supki
supki / pemis.py
Last active December 14, 2015 11:59
Always easy to read.
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
@supki
supki / pemis.rkt
Created February 21, 2013 18:25
proglang week 5 tests
#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.
@supki
supki / async.hs
Created February 19, 2013 11:53
Asynchronous jobs up to N simultaniously
{-# LANGUAGE ViewPatterns #-}
module Main where
import Control.Applicative
import Control.Concurrent
import Control.Concurrent.Async
import Data.List (delete)
import System.Environment (getArgs)
@supki
supki / pemis.sml
Created February 3, 2013 18:11
proglang week 3 tests
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"
@supki
supki / pemis.py
Last active December 5, 2017 21:01
Lists cartesian product oneliner in python.
from os import popen
def f(xs):
return eval(popen("""ghc -ignore-dot-ghci -e "sequence %s" """ % xs).read())
@supki
supki / pe61.hs
Created January 25, 2013 14:14
Project Euler Problem 61.
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