Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Functional or not?

Name: Anonymous 2010-12-23 17:29

Let's say I wrote a function like this:


(defun count-up-to (n)
  (let ((num 0))
    (labels ((count-up ()
               (when (> n num)
                 (format t "~A / ~A~%" (1+ num) n)
                 (incf num)
                 (count-up))))
      (count-up))))


Would this function be considered functional or not?

Name: Anonymous 2010-12-23 23:10

>>1
If your function doesnt change global variables, you should be okey. Anyway, IRL all functions are "functional", they just replace whole global state with new state. So this "functional" term is just mathematical nonsense. But usually you want to decompose and localize changes, whenever possible.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List