• Re: Can someone please explain me what's wrong with this code ?

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Thu Jun 19 08:12:34 2025
    From Newsgroup: comp.lang.lisp

    (defun some-thing-pos (list test)
    (loop for e in list
    for pos upfrom 0
    for res = (funcall test e)
    when res return (list res e pos res))) ;; order to fit name

    Instead of CL, let's use a Lispy language.

    Gauche Scheme

    (define (search L test)
    (any
    (lambda (e i)
    (and-let* ((res (test e))) (list e i res)))
    L
    (liota)))

    (search '(0 2 4 5 7 8 9) odd?)
    ===>
    (5 3 #t)

    (search '(0 2 4 5 7 8 9) negative?)
    ===>
    #f
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp,comp.lang.scheme on Thu Jul 3 13:29:11 2025
    From Newsgroup: comp.lang.lisp

    Ken Tilton wrote:

    (defun some-thing-pos (list test)
    (loop for e in list
    for pos upfrom 0
    for res = (funcall test e)
    when res return (list res e pos res))) ;; order to fit name

    I must say, however, I am suspicous of the whole business, and would
    like to see the calling code so we can really rake this bum over the coals.

    Gauche Scheme

    (use srfi-42) ;; first-ec

    (define (position things test)
    (first-ec #f
    (:list e (index i) things)
    (if (test e))
    (list i e)))

    (position '(oh sun is happen four)
    (lambda(s) (> (string-length (x->string s)) 4)))
    ===>
    (3 happen)
    --- Synchronet 3.21d-Linux NewsLink 1.2