-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.gr
31 lines (23 loc) · 912 Bytes
/
string.gr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import String from "string"
import Array from "array"
import List from "list"
import Char from "char"
import { isDigit } from "./char"
export let words = string => String.split(" ", string)
export let unwords = words => Array.join(" ", words)
export let lines = string =>
String.split(
"\n",
String.implode(Array.filter(c => c != '\r', String.explode(string)))
)
export let unlines = lines => Array.join("\n", lines)
export let every = (predicate, string) =>
Array.every(predicate, String.explode(string))
export let some = (predicate, string) =>
Array.some(predicate, String.explode(string))
export let containsChar = (char, string) =>
String.contains(Char.toString(char), string)
export let map = (fn, string) =>
String.implode(Array.map(fn, String.explode(string)))
export let empty = string => String.length(string) == 0
export let notEmpty = string => String.length(string) != 0