Skip to content

Instantly share code, notes, and snippets.

View osa1's full-sized avatar

Ömer Sinan Ağacan osa1

View GitHub Profile
@osa1
osa1 / gist:6498197
Last active December 22, 2015 16:18
lua return val
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
> print((function () end)())
> a = (function () end)()
> print(a)
nil
@osa1
osa1 / gist:7032758
Created October 17, 2013 21:44
shunting yard
{-# OPTIONS_GHC -Wall #-}
module ShuntingYard where
import qualified Data.Map as M
data Op = Op String Prec Assoc
| OLParen | ORParen deriving (Show)
type Prec = Int
{-# LANGUAGE LambdaCase, GeneralizedNewtypeDeriving #-}
{-# OPTIONS_GHC -Wall #-}
import Data.Array.IArray
import Debug.Trace
stream :: Array Int String
stream = listArray (0, length lst - 1) lst
where
lst = [ "(", "!", "string", "?", "string", ")", "?", "string" ]
@osa1
osa1 / gist:7089333
Created October 21, 2013 19:17
memoized parsers in CPS
function fail(reason)
return { status = "failure", reason = reason }
end
function success(ret, idx)
return { status = "success", token = ret, new_idx = idx }
end
function token(tok)
return function (stream, idx, cont)
@osa1
osa1 / gist:7621898
Last active December 29, 2015 05:29
epic chat log from Love2D irc channel at oftc
[20:25] --> minerva ([email protected]) has joined this channel.
[20:25] <minerva> hello all
[20:25] <YHWH> yo
[20:25] <minerva> i need some advice from some guys
[20:26] <YHWH> most of us are guys
[20:26] <YHWH> if not lal of us
[20:26] <YHWH> all, too
[20:26] <minerva> wow
[20:26] <minerva> ok den
[20:26] <minerva> i had a sort of date last night
@osa1
osa1 / gist:7930901
Last active December 31, 2015 03:59
graph reduction(G-machine) example
ghci> putStr $ runProg "main = S K K 3"
1) Stk [ 1: NSupercomb main [ ] ]
Heap [ 1: NSupercomb main [ ]
2: NSupercomb I [ x ]
3: NSupercomb K [ x y ]
4: NSupercomb K1 [ x y ]
5: NSupercomb S [ f g x ]
6: NSupercomb compose [ f g x ]
7: NSupercomb twice [ f ] ]
@osa1
osa1 / gist:8015396
Last active December 31, 2015 16:39
CMakeLists change to make dolphin-emu working under Linux systems with system-wide SDL installed
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a4dcf97..8878284 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -557,27 +557,10 @@ if(OPENAL_FOUND)
endif()
if(NOT ANDROID)
- if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- include(FindSDL2 OPTIONAL)
{-# LANGUAGE MultiParamTypeClasses,
FunctionalDependencies,
FlexibleInstances #-}
class Option a b | a -> b where
toOption :: a -> Maybe b
instance Option (Maybe a) a where
toOption = id
{-# LANGUAGE NoMonomorphismRestriction #-}
module Test where
-------------------------------------------------------------------------------
import Blaze.ByteString.Builder
import Control.Applicative
import Control.Monad.Identity
import Control.Monad.IO.Class
➜ idris git:(master) ✗ diffstat parser.diff
Parser.hs | 307 +++++++++++++++++++-------------------------------------------
1 file changed, 99 insertions(+), 208 deletions(-)