Created
August 11, 2012 13:29
-
-
Save cmpitg/3324442 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun suml (lst res) | |
(if (zerop (list-length lst)) | |
res | |
(suml (rest lst) (+ res (first lst))))) | |
(suml '(1 2 3 4 5) 0) |
Thầy ơi. Em không hiểu đoạn sau ạ: (suml (rest lst) (+ res (first lst))) Sẽ gọi hàm suml với 2 tham số (res lst) và (+ res (first list)). Nhưng cái (first list) sẽ trả về phần tử đầu tiên của list, như vậy lấy res của list đó thế nào ạ? :-(
res
là "result" mà bạn. Bạn đọc kỹ lại nhé, rest
với res
là khác nhau đấy nhé.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ồ. Phải dùng 2 tham số. Hay thiệt. :-)