brilo
Functions
pub fn iterator_from_string(string: String) -> Iterator(String)
Creates an iterator that yields each grapheme from the given string.
Examples
iterator_from_string("abcd")
|> to_list
// -> ["a", "b", "c", "d"]
pub fn iterator_window(
i: Iterator(a),
by n: Int,
) -> Iterator(Iterator(a))
Returns an iterator of sliding windows.
Examples
iterator.from_list([1,2,3,4,5])
|> iterator_window(3)
|> iterator.map(iterator.to_list)
|> iterator.to_list
// -> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
window([1, 2], 4)
// -> []
pub fn iterator_window_by_2(i: Iterator(a)) -> Iterator(#(a, a))
Returns an iterator of tuples containing two contiguous elements.
Examples
iterator_window_by_2([1,2,3,4])
|> iterator.to_list
// -> [#(1, 2), #(2, 3), #(3, 4)]
iterator_window_by_2([1])
|> iterator.to_list
// -> []
pub fn string_translate(
string: String,
with translations: List(#(String, String)),
) -> String
Creates a new String
by applying all given replacement pairs
Example
string_translate("www.example.com", with: [#(".", "-"), #("com", "net")])
// -> "www-example-net"