Move chomp function into its own util file

This commit is contained in:
Asumu Takikawa 2014-01-06 17:47:55 -05:00
parent f0ebfee9ac
commit 4d448785cd
2 changed files with 12 additions and 7 deletions

View File

@ -0,0 +1,11 @@
#lang racket/base
(provide chomp)
;; removes newline (if any) at end of string
(define (chomp str)
(define len (string-length str))
(if (eq? #\newline (string-ref str (sub1 len)))
(substring str 0 (sub1 len))
str))

View File

@ -6,6 +6,7 @@ don't depend on any other portion of the system
|#
(require syntax/source-syntax "disappeared-use.rkt"
"string.rkt"
racket/list racket/match racket/promise racket/string
syntax/parse (for-syntax racket/base syntax/parse)
(only-in unstable/sequence in-slice))
@ -163,13 +164,6 @@ don't depend on any other portion of the system
(apply tc-error/delayed #:stx stx final-msg (reverse vals))
(apply tc-error/stx stx final-msg (reverse vals))))
;; helper for above, remove \n at end if any
(define (chomp str)
(define len (string-length str))
(if (eq? #\newline (string-ref str (sub1 len)))
(substring str 0 (sub1 len))
str))
;; produce a type error, using the current syntax
(define (tc-error msg . rest)
(let* ([ostx (current-orig-stx)]