2011-09-30 84 views
4

如何测试两个函数变量指向相同的函数?测试两个函数变量指向相同的函数吗?

test = lm 
test2 = lm 

test == lm  # error: comparison (1) is possible only for atomic and list types 
test == test2 # error: comparison (1) is possible only for atomic and list types 
+0

注意这两个功能不“点”相同的功能,它们是LM功能代码的独立_copies_。 – Spacedman

+0

正确...功能性编程=) – SFun28

回答

7

尝试:

identical(test, lm) 
identical(test, test2) 
+0

很好用!谢谢! – SFun28