Contents

Name

SUtils - Various Utility Functions

Synopsis

  Welcome to MzScheme version 300, Copyright (c) 2004-2005 PLT Scheme Inc.
  > (require (planet "sutil.scm" ("oesterholt"  "ho-utils.plt"  1 0)))
  > (glob "d:/build/sutil/*.scm")
  ("d:/build/sutil/scfg.scm" "d:/build/sutil/sprefs.scm" "d:/build/sutil/sutil.scm" "d:/build/sutil/units.scm")
  > (glob "d:/build/sutil/*.pod")
  ("d:/build/sutil/index.pod" "d:/build/sutil/index.pod~")
  > (glob "d:/build/sutil/*.pod$")
  ("d:/build/sutil/index.pod")
  > (basename "d:/build/sutil/index.pod")
  "index.pod"
  > (basedir (build-path "d:/build/sutil/index.pod"))
  "d:/build/sutil/"
  > (home)
  "C:\\Documents and Settings\\hdijkema\\."

  > (home "local" "test")
  "C:\\Documents and Settings\\hdijkema\\local\\test"

  > (mkdir-p (home "local" "test"))
  <executes make-directory* if directory doesn't exist already>
  > (define a 10)
  > (post++ a)
  10
  > a
  11
  > (++ a)
  12
  a
  12
  >(let ((i 0)) (while (< i 10) (display i)(++ i)) (newline))
 0123456789
 >(llet (( (a b c) (list 1 2 3) ))
    (display (format "~a, ~a, ~a~%" a b c)))
 1 2 3
 >
  >(require (lib "time.ss" "srfi" "19"))
  >(define a (current-date));
  >(sleep 3)(define b (current-date));
  >(date<? a b)
  #t
  >(date>? a b)
  #f
 And we've also got 'date<=?', 'date>=?' and 'date=?'

API

srfi:date functions

(date<? dt1:srfi:date dt2:srfi:date) : boolean

returns #t, if dt1<dt2; #f otherwise.

(date>=? dt1:srfi:date dt2:srfi:date) : boolean

returns #t, if dt1>=dt2; #f otherwise.

(date>? dt1:srfi:date dt2:srfi:date) : boolean

returns #t, if dt1>dt2; #f otherwise.

(date<=? dt1:srfi:date dt2:srfi:date) : boolean

returns #t, if dt1<=dt2; #f otherwise.

(date=? dt1:srfi:date dt2:srfi:date) : boolean

returns #t, if dt1=dt2; #f otherwise.

(leap-year? dt:srfi:date) : boolean

returns #t, if dt is a leap year; #f otherwise.

(valid-date? year:number month:number day:number) : boolean

returns #t, year, month and day form a valid date.

Directory browsing

(glob file-pattern:path or string) : list of file:string

returns a list of files that match the given file pattern (empty list if nothing has been found).

(basedir path:path or string) : directory part of path:string

returns the directory part of a given path.

(basename path:path or string) : name of file:string

returns the name part of a given path, or "" if path is a directory.

(mkdir-p path:path or string) : undefined

calls 'make-directory*' if path does not already exist.

Incrementing

(post++ x:number) : number (x)

Increments x, but returns it's original value.

(++ x:number) : number

Increments x and returns the incremented value.

Language constructs

(while expression b1 ...)

Creates a while loop using expression as a continue rule. See also Synopsis.

llet

"List let". With llet it is possible to assign a list returned by a function to individual variables (like perls construction: ($a,$b,$c)=f(10);)

String utils

(substr S:string from:integer . to:integer) : string

A perl like substr. If to isn't given, returns the part of S from 'from' until the end of S. Otherwise, does a (substring S from to). Prevents errors. Constrains the operation to what is possible with S.

Info

(c) 2005 Hans Oesterholt-Dijkema. Distributed undef LGPL. Contact: send email to hans in domain elemental-programming.org. Homepage: http://www.elemental-programming.org.