Skip to content

Instantly share code, notes, and snippets.

@NalaGinrut NalaGinrut/ft2.scm
Created Jul 20, 2012

What would you like to do?
the shortest snake arrange algorithm
#! /usr/local/bin/guile \
-e main -s
(define (main . args)
(let* ((ll ((@ (srfi srfi-1) iota) (read) 1)) (len (length ll)) (m (1- (/ len 2))))
(display len)(newline)
(let lp((a (list-head ll (1+ m))) (b (list-tail ll (1+ m))) (n 1))
(and (< n len) (for-each (lambda (x y) (display x)(display " ")(display y)(display " ")) a b)(newline)
(lp (append (list 1 (car b)) (cdr a)) (append (cdr b) (list (list-ref a m))) (1+ n))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.