Sha256: 5ef2bb31be42cdaa6a19e1779ed29830c33d720a17640ba048c105606af59bb4

Contents?: true

Size: 677 Bytes

Versions: 129

Compression:

Stored size: 677 Bytes

Contents

(defpackage #:sublist
  (:use #:common-lisp)
  (:export #:sublist))

(in-package #:sublist)

(defun is-prefix-of (xs ys)
  (cond ((null xs)                 T)
        ((null ys)                 NIL)
        ((equal (car xs) (car ys)) (is-prefix-of (cdr xs) (cdr ys)))
        (T                         NIL)))

(defun sublist-of (xs ys)
  (if (and xs (null ys))
    nil
    (or (is-prefix-of xs ys) (sublist-of xs (cdr ys)))))

(defun sublist (xs ys)
  (let ((sub   (sublist-of xs ys))
        (super (sublist-of ys xs)))
    (cond ((and sub super) "equal")
          (sub             "sublist")
          (super           "superlist")
          (T               "unequal"))))

Version data entries

129 entries across 129 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.77 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.76 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.75 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.74 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.73 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.72 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.71 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.70 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.69 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.68 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.67 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.66 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.65 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.64 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.63 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.62 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.61 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.60 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.59 tracks/common-lisp/exercises/sublist/example.lisp