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 22:22

>>6
Yes, that's why I'm asking.
The function is completely self-contained and doesn't change behavior based on any state outside of it and doesn't have any side-effects except for what it does internally (ignore format). So if you look at it as some kind of black box wouldn't that make it functional in a sense?

I probably should have left out the format from the start to make it more clear what I mean.

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