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.180 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.179 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.178 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.177 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.176 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.175 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.174 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.173 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.172 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.171 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.170 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.169 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.167 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.166 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.165 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.164 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.163 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.162 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.161 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.160 tracks/common-lisp/exercises/sublist/example.lisp