#!/usr/bin/guile \ -e main -s !# ;;; Copyright 2005 Daniel Cer (daniel.cer@cs.colorado.edu) ;;; ;;; This work is licensed under the Creative Commons Attribution-NonCommercial- ;;; ShareAlike License. To view a copy of this license, visit ;;; http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to ;;; Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, ;;; 94105, USA. (define (read-items input-port) ; read in items from input-port (let ((in-line (read-line input-port))) (if (eof-object? in-line) '() (append (list (string->number in-line)) (read-items input-port))))) (define (main args) (if (not (equal? (length args) 2)) (display (string-append "Usage:\n\t" (car args) " (file with numbers to sort)\n")) (map (lambda (item) (display item) (newline)) ; display items (sort ; sort them (call-with-input-file (car (cdr args)) read-items) <)) ; read them in ))