Skip to content

Instantly share code, notes, and snippets.

View Rembane's full-sized avatar
🔥

Andreas Ekeroot Rembane

🔥
View GitHub Profile
import Prelude hiding (map)
map :: (a -> b) -> [a] -> [b]
map f xs = foldr (\x acc -> f x:acc) [] xs
main :: IO ()
main = print $ map (+2) [1,2,3,4,5,6,7,8,9,10]
@Rembane
Rembane / Main.hs
Last active October 3, 2022 20:31
module Main where
{-|
Module : Main
Description : A Reversed Polish Notation interpreter
A naive implementation implemented as a proof of concept. Among the possible future work is:
- Error checking more advanced than just crashing.
- A translator to infix notation.
" Kill trailing whitespace
function! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
@Rembane
Rembane / Main.hs
Created November 27, 2018 19:48
The order of StateT and ReaderT.
{-# LANGUAGE FlexibleContexts, GeneralizedNewtypeDeriving #-}
module Main where
import Control.Monad.Reader
import Control.Monad.State.Strict
newtype MyStackT1 m r s a = MyStackT1
{ runMyStackT1 :: ReaderT r (StateT s m) a }
deriving (Functor, Applicative, Monad, MonadReader r, MonadState s, MonadIO)
@Rembane
Rembane / speedtest.hs
Last active June 19, 2018 08:17 — forked from kuribas/speedtest.c
speedtest
module Main where
import Data.List
f :: Int -> Int -> Int
f x y = x + (y * 2)
sum' :: [Int] -> Int
sum' = foldl' (+) 0
g :: Int -> Int

How to upgrade to Purescript 0.12

Before we begin, the type search in Pursuit is a great way to search for the functions you need.

Reset your tooling by deleting the bower_components/, .psci_modules/, .pulp-cache/, .psc-package/ and output/ folders. Then run psc-package build --only-dependencies.

Import changes and effects

Using sed or your other favourite global replace tool to search and replace all occurences in the list

Keybase proof

I hereby claim:

  • I am Rembane on github.
  • I am eqroot (https://keybase.io/eqroot) on keybase.
  • I have a public key whose fingerprint is A05D 2DCD 038E 751E B1A1 DDDD 88AA 23B7 AEA5 8DCE

To claim this, I am signing this object:

from collections import Counter
from operator import itemgetter
# Javascript för att hämta data från val.sverok.se.
# Array.from(document.querySelectorAll('#content > div > table > tbody > tr td:nth-child(4)')).map(x => x.textContent).join(', ')
# Resulterande data.
orter = "Skövde , Helsingborg  , Trollhättan , Ålberga , Upplands Väsby , Lövestad ,  , Göteborg , Nybro , Göteborg ,  ,  , Norrköping , Malmö ,  ,  , Hagfors ,  , Kalmar ,  , Kristinehamn  , Linköping , Göteborg  , Lindome , Krokom ,  ,  , Jönköping ,  ,  ,  , Göteborg , Lund , Göteborg ,  ,  , Göteborg , Malmö , Karlstad , Göteborg ,  ,  , Lund , Norrköping , Norrköping , Malmö , Jonkoping ,  , Malmö ,  ,  , Göteborg , Burträsk , Västervik , Visby , Sävar , Lund , Staffanstorp , Västerås , Göteborg ,  , Limhamn , Göteborg , Linköping ,  ,  ,  , Huskvarna  , Eskilstuna , Norrköping , Karlskrona , Linköping , Tyringe , Luleå , Göteborg , Farsta ,  , Stockholm ,  , UMEÅ , Ålberga , Lund ,  , Skövde ,  ,  , Genarp ,  , Malmö ,  , Rydsgård , Karlsh
runRandom :: State StdGen a -> IO a
runRandom x = do
g <- newStdGen
return $ evalState x g
#include <stdio.h>
int main() {
int x = 42;
int *p = &x;
printf("Value of the cosplayer: %d", p);
}