Skip to main content
deleted 4 characters in body
Source Link
rnso
  • 1.7k
  • 10
  • 8

UngolfedOutput:

Ungolfed:

Output:

deleted 31 characters in body
Source Link
rnso
  • 1.7k
  • 10
  • 8
(define (f s cl)
  (let ((lr list-ref)
        (ls list-set)
        (sl string-length)
        (ss substring)
        (l (string-split s "\n")))
    (let loop ((changed #f))
      (for ((i (sub1 (length l))))
        (let* ((s (lr l i))
               (r (lr l (add1 i)))
               (n (sl s))
               (m (sl r)))
               (when (> n m)
                 (set! l (ls l i (ss s 0 m)))
                 (set! l (ls l (add1 i)(string-append r (ss s m n))))
                 (set! changed #t))))
        (if changed (loop #f)
            (begin
              (let* ((l (for/list ((i l))
                          (string-trim i)))
                     (l (string-join l))
                     (l (string-replace l " " "")))
                (ormap (λ(x) (equal? x l)) cl)))
            ))))
(define (f s cl)
  (let ((lr list-ref)
        (ls list-set)
        (sl string-length)
        (ss substring)
        (l (string-split s "\n")))
    (let loop ((changed #f))
      (for ((i (sub1 (length l))))
        (let* ((s (lr l i))
               (r (lr l (add1 i)))
               (n (sl s))
               (m (sl r)))
               (when (> n m)
                 (set! l (ls l i (ss s 0 m)))
                 (set! l (ls l (add1 i)(string-append r (ss s m n))))
                 (set! changed #t))))
        (if changed (loop #f)
            (begin
              (let* ((l (for/list ((i l))
                         (string-trim i)))
                     (l (string-join l))
                     (l (string-replace l " " "")))
                (ormap (λ(x) (equal? x l)) cl)))
            ))))
(define (f s cl)
  (let ((lr list-ref)
        (ls list-set)
        (sl string-length)
        (ss substring)
        (l (string-split s "\n")))
    (let loop ((changed #f))
      (for ((i (sub1 (length l))))
        (let* ((s (lr l i))
               (r (lr l (add1 i)))
               (n (sl s))
               (m (sl r)))
               (when (> n m)
                 (set! l (ls l i (ss s 0 m)))
                 (set! l (ls l (add1 i)(string-append r (ss s m n))))
                 (set! changed #t))))
        (if changed (loop #f)
            (begin
              (let* ((l (for/list ((i l))
                          (string-trim i)))
                     (l (string-join l))
                     (l (string-replace l " " "")))
                (ormap (λ(x) (equal? x l)) cl)))
            ))))
deleted 31 characters in body
Source Link
rnso
  • 1.7k
  • 10
  • 8

Racket 471446 bytes

(let((lr list-ref)(ls list-set)(sl string-length)(ss substring)
 (l(string-split s "\n")))(let loop((changed #f))(for((i(sub1(length l)))) 
(define let*((s(lr l i))(define r(lr l(add1 i)))
 (define n(sl s))(define m(sl r)))(when(> n m)(set! l(ls l i(ss s 0 m)))(set! l(ls l(add1 i) 
(string-append r(ss s m n))))
 (set! changed #t))))(if changed(loop #f)(begin(let*((l(for/list((i l))(string-trim i)))(l(string-join l)) 
(l(string-replace l " " "")))
 (ormap(lambdaλ(x)(equal? x l))cl))))))
(define (f s cl)
  (let ((lr list-ref)
        (ls list-set)
        (sl string-length)
        (ss substring)
        (l (string-split s "\n")))
    (let loop ((changed #f))
      (for ((i (sub1 (length l))))
        (definelet* ((s (lr l i))
        (define       (r (lr l (add1 i)))
        (define       (n (sl s))
        (define       (m (sl r)))
               (when (> n m)
                 (set! l (ls l i (ss s 0 m)))
                 (set! l (ls l (add1 i)(string-append r (ss s m n))))
                 (set! changed #t))))
        (if changed (loop #f)
            (begin
              (let* ((l (for/list ((i l))
                         (string-trim i)))
              ))
            (l (string-join l))
                     (l (string-replace l " " "")))
                (ormap (lambdaλ(x) (equal? x l)) cl)))
            )
          ))))

Racket 471 bytes

(let((lr list-ref)(ls list-set)(sl string-length)(ss substring)
 (l(string-split s "\n")))(let loop((changed #f))(for((i(sub1(length l))))(define s(lr l i))(define r(lr l(add1 i)))
 (define n(sl s))(define m(sl r))(when(> n m)(set! l(ls l i(ss s 0 m)))(set! l(ls l(add1 i)(string-append r(ss s m n))))
 (set! changed #t)))(if changed(loop #f)(begin(let*((l(for/list((i l))(string-trim i)))(l(string-join l))(l(string-replace l " " "")))
 (ormap(lambda(x)(equal? x l))cl))))))
(define (f s cl)
  (let ((lr list-ref)
        (ls list-set)
        (sl string-length)
        (ss substring)
        (l (string-split s "\n")))
    (let loop ((changed #f))
      (for ((i (sub1 (length l))))
        (define s (lr l i))
        (define r (lr l (add1 i)))
        (define n (sl s))
        (define m (sl r))
        (when (> n m)
          (set! l (ls l i (ss s 0 m)))
          (set! l (ls l (add1 i)(string-append r (ss s m n))))
          (set! changed #t)))
      (if changed (loop #f)
          (begin
            (let* ((l(for/list ((i l))
              (string-trim i)
              ))
            (l(string-join l))
            (l (string-replace l " " "")))
            (ormap (lambda(x) (equal? x l)) cl))
            )
          ))))

Racket 446 bytes

(let((lr list-ref)(ls list-set)(sl string-length)(ss substring)(l(string-split s "\n")))(let loop((changed #f))(for((i(sub1(length l)))) 
(let*((s(lr l i))(r(lr l(add1 i)))(n(sl s))(m(sl r)))(when(> n m)(set! l(ls l i(ss s 0 m)))(set! l(ls l(add1 i) 
(string-append r(ss s m n))))(set! changed #t))))(if changed(loop #f)(begin(let*((l(for/list((i l))(string-trim i)))(l(string-join l)) 
(l(string-replace l " " "")))(ormap(λ(x)(equal? x l))cl))))))
(define (f s cl)
  (let ((lr list-ref)
        (ls list-set)
        (sl string-length)
        (ss substring)
        (l (string-split s "\n")))
    (let loop ((changed #f))
      (for ((i (sub1 (length l))))
        (let* ((s (lr l i))
               (r (lr l (add1 i)))
               (n (sl s))
               (m (sl r)))
               (when (> n m)
                 (set! l (ls l i (ss s 0 m)))
                 (set! l (ls l (add1 i)(string-append r (ss s m n))))
                 (set! changed #t))))
        (if changed (loop #f)
            (begin
              (let* ((l (for/list ((i l))
                         (string-trim i)))
                     (l (string-join l))
                     (l (string-replace l " " "")))
                (ormap (λ(x) (equal? x l)) cl)))
            ))))
deleted 118 characters in body
Source Link
rnso
  • 1.7k
  • 10
  • 8
Loading
Source Link
rnso
  • 1.7k
  • 10
  • 8
Loading