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.159 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.158 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.157 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.156 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.155 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.154 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.153 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.152 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.151 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.150 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.149 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.148 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.147 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.146 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.145 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.144 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.143 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.142 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.141 tracks/common-lisp/exercises/sublist/example.lisp
trackler-2.2.1.140 tracks/common-lisp/exercises/sublist/example.lisp