lisp

Why does `sxhash` return a constant for all structs?

情到浓时终转凉″ 提交于 2020-12-05 03:42:32
问题 When using the Common Lisp sxhash function on structs I'm getting the same value for all structs (in SBCL only structs of the same type). For instance, the following code prints two lists of integers all of which have the same value. (progn (defstruct foo data) (print (mapcar #'sxhash (loop for i below 10 collect (make-foo :data i)))) (defstruct bar data) (print (mapcar #'sxhash (loop for i below 10 collect (make-bar :data i))))) ;;; Allegro (319 319 319 319 319 319 319 319 319 319) (319 319

Why does `sxhash` return a constant for all structs?

柔情痞子 提交于 2020-12-05 03:40:50
问题 When using the Common Lisp sxhash function on structs I'm getting the same value for all structs (in SBCL only structs of the same type). For instance, the following code prints two lists of integers all of which have the same value. (progn (defstruct foo data) (print (mapcar #'sxhash (loop for i below 10 collect (make-foo :data i)))) (defstruct bar data) (print (mapcar #'sxhash (loop for i below 10 collect (make-bar :data i))))) ;;; Allegro (319 319 319 319 319 319 319 319 319 319) (319 319

What's the difference between ' and #' in Lisp?

柔情痞子 提交于 2020-11-26 08:12:02
问题 It seems both (mapcar 'car '((foo bar) (foo1 bar1))) and (mapcar #'car '((foo bar) (foo1 bar1))) work as the same. And I also know ' means (quote symbol) and #' means (function function-name). But what's the underlying difference? Why these 2 both work in previous mapcar ? 回答1: 'foo evaluates to the symbol FOO. #'foo evaluates to the function bound to the name FOO. In Lisp a symbol can be called as a function when the symbol FOO has a function binding. Here CAR is a symbol that has a function

What's the difference between ' and #' in Lisp?

大兔子大兔子 提交于 2020-11-26 08:07:30
问题 It seems both (mapcar 'car '((foo bar) (foo1 bar1))) and (mapcar #'car '((foo bar) (foo1 bar1))) work as the same. And I also know ' means (quote symbol) and #' means (function function-name). But what's the underlying difference? Why these 2 both work in previous mapcar ? 回答1: 'foo evaluates to the symbol FOO. #'foo evaluates to the function bound to the name FOO. In Lisp a symbol can be called as a function when the symbol FOO has a function binding. Here CAR is a symbol that has a function

What's the difference between ' and #' in Lisp?

元气小坏坏 提交于 2020-11-26 08:06:47
问题 It seems both (mapcar 'car '((foo bar) (foo1 bar1))) and (mapcar #'car '((foo bar) (foo1 bar1))) work as the same. And I also know ' means (quote symbol) and #' means (function function-name). But what's the underlying difference? Why these 2 both work in previous mapcar ? 回答1: 'foo evaluates to the symbol FOO. #'foo evaluates to the function bound to the name FOO. In Lisp a symbol can be called as a function when the symbol FOO has a function binding. Here CAR is a symbol that has a function