google / lisp-koans

Common Lisp Koans is a language learning exercise in the same vein as the ruby koans, python koans and others. It is a port of the prior koans with some modifications to highlight lisp-specific features. Structured as ordered groups of broken unit tests, the project guides the learner progressively through many Common Lisp language features.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

string-equal in equality-distinctions.lsp

filipk opened this issue · comments

It would be valuable to include koans on STRING-EQUAL and STRING= in equality-distinctions.lsp (especially how these functions differ from EQUAL and EQUALP).

Examples from here: http://www.lispworks.com/documentation/HyperSpec/Body/f_stgeq_.htm

(define-test test-string-equal
  "string-equal is just like string= except that differences in case are ignored."
  (true-or-false? ___ (string= "Foo" "Foo"))
  (true-or-false? ___ (string= "Foo" "FOO"))
  (true-or-false? ___ (string= "together" "frog" :start1 1 :end1 3 :start2 2))
  (true-or-false? ___ (string-equal "Foo" "FOO"))
  (true-or-false? ___ (string-equal "Foo" "FOO")))
  (true-or-false? ___ (string-equal "together" "FROG" :start1 1 :end1 3 :start2 2))

That's a fine example of differences between STRING-EQUAL and STRING= but that still doesn't explain in what way EQUAL and EQUALP differ. Nevertheless you should make a pull request out of it, I'd say.

OK. I will work on to make examples differ to EQUAL and EQUALP. Thank you!

How about add a clarify note:

; EQ, EQL, EQUAL, and EQUALP are general equality predicates.
; Additionally, Lisp also provides the type-specific predicates.
; For example, STRING= and STRING-EQUAL are predicates for strings.
(define-test test-string-equal
  "string-equal is just like string= except that differences in case are ignored."
  (true-or-false? ___ (string= "Foo" "Foo"))
  (true-or-false? ___ (string= "Foo" "FOO"))
  (true-or-false? ___ (string= "together" "frog" :start1 1 :end1 3 :start2 2))
  (true-or-false? ___ (string-equal "Foo" "FOO"))
  (true-or-false? ___ (string-equal "Foo" "FOO")))
  (true-or-false? ___ (string-equal "together" "FROG" :start1 1 :end1 3 :start2 2))

Actually, you nailed it on the first time but I noticed the difference only now, as you wrote "type-specific". STRING= and STRING-EQUAL support additional, STRING-specific parameters :start1, :start2, :end1 and :end2. So, your last example is just right. Thanks!