aboutsummaryrefslogtreecommitdiff
path: root/ExtraString.icl
blob: d1283260d714ceb97b9491760903cf458db292c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
implementation module ExtraString

import StdEnv

matches :: !String !String -> Bool
matches needle haystack = haystack % (0, size needle - 1) == needle

skip :: !Int !String -> String
skip i s = s % (i, size s - 1)

join :: !String ![a] -> String | toString a
join del [] = ""
join del [s:ss] = toString s +++ del +++ join del ss

:: TextColor = Red | Green | None

color :: TextColor !String -> String
color Red s   = "\x1B[31m" +++ s +++ "\x1B[0m"
color Green s = "\x1B[32m" +++ s +++ "\x1B[0m"
color None s  = "\x1B[0m" +++ s +++ "\x1B[0m"