Or am I doing something wrong, or it does not work)

(define ln (lambda (list) (cond ((eq? list () 0) (#t (+ (ln (cdr list)) 1)) )))) 
  • Yes, you do not do it - you consider the elements, but you must return the element - Grundy
  • Why is the topic of the question radically changed from counting the quantity to receiving the latter? - Grundy
  • changed the subject of the task))) - Svyatoslav Palii
  • you don’t have to do this, it’s better to ask a new question, and not to completely change the contents of the old one

1 answer 1

In general, there is a function last , but like this:

 (define (last-el l) (cond ((null? (cdr l)) (car l)) (else (last-el (cdr l))))) 
  • thank you) just in Schme nil)) - Svyatoslav Palii
  • you work out, go deep. I envy you if you teach this in high school. - 11111000000
  • my soul does not burn before that) I see myself in a frost end) and thanks again for the help) - Svyatoslav Paliy
  • 2
    Please, with pleasure. But then I will surprise you: Javascript has a lot in common with Scheme, much more than with Java, despite the name, C-like syntax and semicolons. raganwald.com/2013/07/19/javascript-is-a-lisp.html A functional programming - the most progressive way to do frontend. In this regard, Clojure + ClojureScript is also popular now, which is also Lisp. - 11111000000