Skip to content

Instantly share code, notes, and snippets.

@takikawa
Created February 26, 2013 04:06
Show Gist options
  • Select an option

  • Save takikawa/5035794 to your computer and use it in GitHub Desktop.

Select an option

Save takikawa/5035794 to your computer and use it in GitHub Desktop.
#lang racket
;; a fun implementation of balanced brackets from Rosetta Code
(define (balanced? str)
(with-handlers ([exn:fail? (λ (exn) #f)])
(define in (open-input-string str)
(let loop ([x (read in)])
(if (not (eof-object? x))
(loop (read in))
#t))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment