Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here are a few tips.</p> <p>The ormap-expression in:</p> <pre><code> (define (in-chars? c chars) (ormap (lambda (ch) (equal? c ch)) (string-&gt;list chars))) </code></pre> <p>can be written as</p> <pre><code> (memv c (string-&gt;list chars)) </code></pre> <p>The if-epression in</p> <pre><code>(define (match pattern text) (define remainders (pattern text)) (if (not (set-empty? remainders)) (substring text 0 (- (string-length text) (string-length (argmin string-length (set-&gt;list remainders))))) #f)) </code></pre> <p>can be written as</p> <pre><code> (and (not (set-empty? remainders)) (substring ...) </code></pre> <p>However your function are small and to the point, so I wouldn't change much.</p> <p>A more convenient syntax for manipulating strings would make it easier to read and write string manipulation programs. Some years ago I made an attempt and wrote a concat macro. </p> <p>I used it to implement Norvig's spelling checker (his original article might interest you). The resulting spelling checker and the concat macro is explained here </p> <p><a href="http://blog.scheme.dk/2007/04/writing-spelling-corrector-in-plt.html" rel="nofollow">http://blog.scheme.dk/2007/04/writing-spelling-corrector-in-plt.html</a></p> <p>Update: I have written an updated version of the spell checker. The concat macro is makes simple string manipulation shorter.</p> <p><a href="https://github.com/soegaard/this-and-that/blob/master/spell-checker.rkt" rel="nofollow">https://github.com/soegaard/this-and-that/blob/master/spell-checker.rkt</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload