Gene Pasquet on Nostr: Is there a better way to write this in scheme? That looks ugly to me: (define ...
Is there a better way to write this in scheme? That looks ugly to me:
(define (player-collides?)
(let ((player-hitbox (vehicle-hitbox player-position)))
(let loop ((vehicles vehicles))
(if (rect-intersects? player-hitbox (vehicle-hitbox (vehicle-position (car vehicles))))
#t
(if (null? (cdr vehicles))
#f
(loop (cdr vehicles)))))))
#lisp #scheme #lispgamejam
Published at
2024-05-22 09:09:25Event JSON
{
"id": "fa29e2ba7079f96d3dfc119ac843ec1b02201025a58941ddaa99f5e5661f20de",
"pubkey": "9e9f848952d5d7577e2639b5a181f15d21f56825d1a467f5f09b6f87475fd955",
"created_at": 1716368965,
"kind": 1,
"tags": [
[
"t",
"t"
],
[
"t",
"f"
],
[
"t",
"lisp"
],
[
"t",
"scheme"
],
[
"t",
"lispgamejam"
],
[
"proxy",
"https://emacs.ch/users/etenil/statuses/112483956552973617",
"activitypub"
]
],
"content": "Is there a better way to write this in scheme? That looks ugly to me:\n\n(define (player-collides?)\n (let ((player-hitbox (vehicle-hitbox player-position)))\n (let loop ((vehicles vehicles))\n (if (rect-intersects? player-hitbox (vehicle-hitbox (vehicle-position (car vehicles))))\n #t\n (if (null? (cdr vehicles))\n #f\n (loop (cdr vehicles)))))))\n\n\n#lisp #scheme #lispgamejam",
"sig": "81e92b498bbfa7e1edd61b12e5600909b35f91bfeca015599889150c3fe9ff31924b67b6659837a9dfe9befc40cca514675becab1c6b2ba15c576009feef3a00"
}