hackerbase/doc/utils.md

1.7 KiB

Utility Modules

To ensure there are no external dependencies (including chicken eggs), these modules re-implement any basic procedures which are required for any algorithms used. And some advanced yet generic functionality as well.

The modules are listed in alphabetical order.

CSV

This module provides a very simple, incomplete and incorrect but fast CSV loader.

(csv-parse filename
	[#:separator #\;]
	[#:string-delimiter #\"])
  • separator - cell separator in CSV file
  • string-delimiter - for introducing strings possibly with separators

Parses given CSV file and returns list of lists of strings representing its contents.

(csv-split-header csv)
  • csv - list of lists of strings

Splits given loaded CSV into two tables at the first empty row.

IO

List

(import util-list)

This module implements basic list functionality which is common in most scheme implementations.

(filter pred? lst)
  • pred? - procedure accepting any value and returning #t or #f
  • lst - list to be filtered

Returns a list containing only elements matching given pred? predicate.

Set (List)

String

(import util-string)

String manipulation functions which are used throughout other modules.

(string-repeat str rep)
  • str - string to repeat
  • rep - number of repeats

Returns a string created by repeating the string str exactly rep number of times.

(string-first+rest str)
  • str - a string to split

Returns a pair of strings where the car of the pair is the first token in the str given and cdr is a string with the remainder with leading whitespace removed.

Tag

Time