My quick summary of Python 2.7 strings and Unicode.
Python has two string types:
- type
str - type
unicode
Examples:
| module Misc | |
| ( withOutputTo | |
| ) where | |
| import System.IO | |
| import GHC.IO.Handle | |
| import Control.Exception | |
| -- | Run an IO action with stdout redirected to a file. | |
| -- Restores stdout upon completion of the action. |
| module SplitFile | |
| ( splitFile, splitFileOn, splitHandle, splitHandleOn, findNext, findNewLine | |
| ) where | |
| import System.IO | |
| import qualified Data.ByteString.Char8 as B | |
| splitFileOn :: (Char -> Bool) -> Int -> FilePath -> IO [Integer] | |
| splitFileOn find parts path = do | |
| h <- openBinaryFile path ReadMode |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| -- Updated for GHC 7.10 | |
| {--------------------------------------------------------------------- | |
| A HASKELL LIBRARY OF MONADIC PARSER COMBINATORS | |
| 17th April 1997 | |
| Graham Hutton Erik Meijer | |
| University of Nottingham University of Utrecht |
| module Lib | |
| where | |
| import Graphics.Gnuplot.Simple | |
| import qualified Graphics.Gnuplot.Terminal.SVG as SVG | |
| foo = do | |
| let zs = [ (x,x) | x <- [1..10] ] | |
| plotList [Key Nothing | |
| ,YRange (0,maximum (map snd zs) + 1) |
| // Solution for [2015-09-11] Challenge #231 [Hard] Eight Husbands for Eight Sisters | |
| // | |
| // https://www.reddit.com/r/dailyprogrammer/comments/3kj1v9/20150911_challenge_231_hard_eight_husbands_for/ | |
| // | |
| // NOTE: This is ugly Java - lots of global variables, etc. | |
| import java.util.Arrays; | |
| import java.util.ArrayList; | |
| import java.util.List; |
| <html> | |
| <body> | |
| <script> | |
| function toChar(ch) { | |
| return (ch == '' ? ' ' : ch) | |
| } | |
| function next(grid) { |
| Emulating an Enigma machine | |
| === | |
| In this gist I'll go over the development of an Enigma machine encoder | |
| in Haskell. | |
| Here are some useful background info about how the Enigma machine works: | |
| - Enigma Simulator: http://enigmaco.de/enigma/enigma.html | |
| - "How Enigma Machines Work" http://enigma.louisedade.co.uk/howitworks.html |
| {-# LANGUAGE Rank2Types #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| import Data.Reflection | |
| import Data.Proxy | |
| data M a s = M a -- Note the phantom comes *after* the concrete | |
| -- In `normalize` we're tying the knot to get the phantom types to align | |
| -- note that reflect :: Reifies s a => forall proxy. proxy s -> a |