View byte_size.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
RUDE = b"\xe3\x80\x82".decode("utf-8")
def limit_slice(maxlen, text):
"""Given a maximum length and text, return the text truncated to the provided
length."""
View main.hs
module Main where
-- | Return a Knuth-Morris-Pratt index for a given string
stringIndex :: String -> [Int]
stringIndex "" = []
stringIndex txt = indexr [0] 0 1 where
indexr :: [Int] -> Int -> Int -> [Int]
indexr rsf subPos chrPos