Skip to content

Instantly share code, notes, and snippets.

View Lifelovinglight's full-sized avatar

Bo Victor Natanael Fors Lifelovinglight

  • Linköping, Sweden
View GitHub Profile
servers = (
{
address = "irc.lainchan.org";
chatnet = "lainchan";
port = "6697";
use_tls = "yes";
tls_verify = "yes";
autoconnect = "yes";
}
);
@Lifelovinglight
Lifelovinglight / term.hs
Last active May 21, 2018 07:14
left-recursive expression reduction example
import Text.Parsec
data Term = Plus Term Term
| Minus Term Term
| Div Term Term
| Mult Term Term
| Number Integer
deriving (Show)
type TermParser a = Parsec String () a
;-*-syntax:COMMON-LISP;Package:(RT :use "COMMON-LISP" :colon-mode :external)-*-
#|----------------------------------------------------------------------------|
| Copyright 1990 by the Massachusetts Institute of Technology, Cambridge MA. |
| |
| Permission to use, copy, modify, and distribute this software and its |
| documentation for any purpose and without fee is hereby granted, provided |
| that this copyright and permission notice appear in all copies and |
| supporting documentation, and that the name of M.I.T. not be used in |
| advertising or publicity pertaining to distribution of the software |
import Data.Monoid
import Control.Monad
import Control.Applicative
(<<>>) :: (Monad m, Monoid a) => m a -> m a -> m a
a <<>> b = (<>) <$> a <*> b
(<<>) :: (Monad m, Monoid a) => m a -> a -> m a
a <<> b = (<>) <$> a <*> (return b)
{-# LANGUAGE TemplateHaskell #-}
import System.IO
import Text.Parsec
import Control.Monad.State
import Control.Monad
import Control.Monad.Loops
import Control.Lens
import Data.Maybe
import Data.Map.Strict (Map)
@Lifelovinglight
Lifelovinglight / adventure.hs
Created September 22, 2017 16:50
how2adventure
data Verb = Look
| Take
| Drop
| Put
deriving (Enum, Show, Eq)
data Thing = Player
| Lantern
| Sword
| Bag
@Lifelovinglight
Lifelovinglight / story.ni
Last active August 11, 2017 07:56
moving alien ai in inform 7
"alien" by "whiteline"
the sick bay is a room.
the corridor is a room.
the freezer is a room.
the sick bay is west of the corridor.
;;;; Fibonacchi recursive tree solution in non-exponential time challenge code.
(defun fib (n)
(check-type n (integer 0 *))
(labels ((fib-inner (n)
(case n
((0) 0)
((1) 1)
(otherwise (+ (fib (- n 1))
(defun convert (string)
(let ((designators '(("0y" . 2)
("0o" . 8)
("0x" . 16))))
(cond ((string= "" string) 0)
((every #'digit-char-p string)
(parse-integer string))
((> (length string) 2)
(parse-integer string
:start 2
struct struct_i_want_to_put_inna_list {
struct list_head nextelem;
int mydata;
};
struct list_head my_list;
INIT_LIST_HEAD(&my_list);
struct struct_i_want_to_put_inna_list *current_elem;