Skip to content

Instantly share code, notes, and snippets.

View prednaz's full-sized avatar

Philipp prednaz

View GitHub Profile
@prednaz
prednaz / ascending_sub_list1.hs
Created September 11, 2019 11:03
list of ascending sub lists, version 1
ascending_sub_list :: Ord element => [element] -> [[element]]
ascending_sub_list = foldr append []
where
append :: Ord element => element -> [[element]] -> [[element]]
append element_new sub_list_list
| sub_list_list_head : sub_list_list_tail <- sub_list_list,
element_new <= head sub_list_list_head
= (element_new : sub_list_list_head) : sub_list_list_tail
| otherwise = [element_new] : sub_list_list
@prednaz
prednaz / ascending_sub_list2.hs
Last active September 11, 2019 12:16
list of ascending sub lists, version 2
import Data.Tuple (swap)
ascending_sub_list :: Ord e => [e] -> [[e]]
ascending_sub_list [] = []
ascending_sub_list list = ascending_sub_list_first_result : ascending_sub_list rest
where (ascending_sub_list_first_result, rest) = ascending_sub_list_first list
-- first ascending sub list and the rest
ascending_sub_list_first :: Ord e => [e] -> ([e], [e])
ascending_sub_list_first [] = ([], [])
@prednaz
prednaz / parse_jost.hs
Created September 14, 2019 10:00
Zentraluebung zu Parsen von Herr Jost
import Prelude hiding (lex)
import Data.Char
import Data.Maybe
import Data.Semigroup
{- Vorlesung "Programmierung und Modellierung"
LMU München, Sommersemester 2019
Steffen Jost
Code zu Folien 7.23ff
newtype Box phantom = Box Bool
unbox :: Box phantom -> Bool
unbox (Box content) = content
myBox :: Show phantom => Box phantom
myBox = Box False
result :: Bool
result = unbox myBox
(global-set-key (kbd "<backtab>") 'indent-for-tab-command)
(add-hook 'haskell-indentation-mode-hook
(lambda ()
(define-key haskell-indentation-mode-map (kbd "<backtab>") 'indent-for-tab-command)))
(defvar haskell-indentation-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "RET") #'haskell-indentation-newline-and-indent)
(define-key map (kbd "<backtab>") #'haskell-indentation-indent-backwards)
(define-key map (kbd ",") #'haskell-indentation-common-electric-command)
(define-key map (kbd ";") #'haskell-indentation-common-electric-command)
(define-key map (kbd ")") #'haskell-indentation-common-electric-command)
(define-key map (kbd "}") #'haskell-indentation-common-electric-command)
(define-key map (kbd "]") #'haskell-indentation-common-electric-command)
map)
{-# LANGUAGE NamedFieldPuns #-}
import XMonad
import XMonad.Config.Desktop
import qualified Data.Map as Map
main :: IO ()
main =
xmonad $ desktopConfig {
terminal = "konsole",
{-# language UndecidableInstances #-}
{-# language FunctionalDependencies #-}
{-# language MultiParamTypeClasses #-}
{-# language DataKinds #-}
{-# language FlexibleInstances #-}
{-# language ExistentialQuantification #-}
{-# language PolyKinds #-}
{-# language TypeOperators #-}
module Main where
{-# language FlexibleInstances #-}
{-# language UndecidableInstances #-}
{-# language TemplateHaskell #-}
{-# language DataKinds #-}
{-# language OverloadedLabels #-}
{-# language MultiParamTypeClasses #-}
{-# language GADTs #-}
module Main where
{-# language BangPatterns #-}
module Main where
import Debug.Trace (trace)
data Source = Source Char Bool
data Intermediate = Intermediate !Char !Bool
data Destination = Destination Char Bool