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 flatten (lst) | |
"flatten nested list" | |
(labels ((flatten-rec (lst acc) | |
(cond ((null lst) acc) | |
((atom lst) (cons lst acc)) | |
(t (flatten-rec | |
(car lst) | |
(flatten-rec (cdr lst) acc)))))) | |
(flatten-rec lst nil))) |
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 print-list (list) | |
(format t "~{~A ~}~%" list)) |
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
import threading | |
# A thread-safe implementation of Singleton pattern | |
# To be used as mixin or base class | |
class Singleton(object): | |
# use special name mangling for private class-level lock | |
# we don't want a global lock for all the classes that use Singleton | |
# each class should have its own lock to reduce locking contention | |
__lock = threading.Lock() |
NewerOlder