Skip to content

Instantly share code, notes, and snippets.

@windymelt windymelt/ball.lisp

Created Jul 26, 2020
Embed
What would you like to do?
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
(ros:ensure-asdf)
#+quicklisp(ql:quickload '(:iterate) :silent t)
)
(defpackage :ros.script.ballfun.3804742596
(:use :cl :iterate))
(in-package :ros.script.ballfun.3804742596)
(defun main (&rest argv)
(declare (ignorable argv))
(let ((*wx* (pop argv))
(*wy* (pop argv)))
(format t "rectangle: (~A,~A)~%" *wx* *wy*)
(iter
(for i from 1)
(with wx = *wx*)
(with wy = *wy*)
(with xacc = 1)
(with yacc = 1)
(for x :initially 1 :then (+ x xacc))
(for y :initially 1 :then (+ y yacc))
(format t "~A: (~A,~A)~%" i x y)
(if-first-time
nil
(progn
(when (or (eq x 1) (eq x wx)) (setf xacc (- xacc)))
(when (or (eq y 1) (eq y wy)) (setf yacc (- yacc)))))
(if-first-time
nil
(until (or (and (eq x 1) (eq y 1))
(and (eq x 1) (eq y wy))
(and (eq x wx) (eq y 1))
(and (eq x wx) (eq y wy)))))
(finally (format t "GOAL!~%") (list x y))))
)
;;; vim: set ft=lisp lisp:
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.