If you put spaces in front of your code, news.yc will indent nicely.
(cond ((or (string=? "hello" my-string)
(string=? "world" my-string))
(print "match")))
(string-case= my-string
(("hello" "world") (print "match")))
That only saves you one quote and one lambda for each clause, right?
(define (string-case= my-string . clauses)
(cond ((null? clauses) 'whatever)
((string-member? my-string (caar clauses))
((cadar clauses)))
(else (apply string-case=
my-string
(cdr clauses)))))
Where string-member? is trivial to define as a procedure too.Then you use it like
(string-case=
('("hello" "world")
(lambda () (print "match"))))
I myself wouldn't use a macro for this little gain.[Edit: I had completely misunderstood the macro.]
If I didn't create a string-case= macro, I would have to write the final expression over and over again. With multiple string-case matches I would have to write string=? many many times:
To do that with the string-case= macro: Saves quite a bit of typing and now I have a good example of why macros are good to have around :Dedit: formatting ftw.