I assign the function to symbol-value but sometimes works sometimes
doesn't. What I don't understand?
(setq plus #'+)
#<Function + 20A6521A>
(mapcar plus '(1 2) '( 3 4))
(4 6)
(setq + #'+)
#<Function + 20A6521A>
CL-USER 14 : 5 > (mapcar plus '(1 2) '( 3 4))
(4 6)
(mapcar + '(1 2) '( 3 4))
Error: Argument to apply/funcall is not a function: (MAPCAR PLUS
(QUOTE (1 2)) (QUOTE (3 4))).
1 (abort) Return to level 5.
2 Return to debug level 5.
3 Return to level 4.
4 Return to debug level 4.
5 Return to level 3.
6 Return to debug level 3.
7 Return to level 2.
8 Return to debug level 2.
9 Return to level 1.
10 Return to debug level 1.
11 Return to level 0.
12 Return to top loop level 0.
Type :b for backtrace, :c <option number> to proceed, or :? for other
options
On Feb 11, 11:37 pm, Slobodan Blazeski <·················@gmail.com>
wrote:
> I assign the function to symbol-value but sometimes works sometimes
> doesn't. What I don't understand?
> (setq plus #'+)
> #<Function + 20A6521A>
>
> (mapcar plus '(1 2) '( 3 4))
> (4 6)
>
> (setq + #'+)
> #<Function + 20A6521A>
> CL-USER 14 : 5 > (mapcar plus '(1 2) '( 3 4))
> (4 6)
>
> (mapcar + '(1 2) '( 3 4))
> Error: Argument to apply/funcall is not a function: (MAPCAR PLUS
> (QUOTE (1 2)) (QUOTE (3 4))).
> 1 (abort) Return to level 5.
> 2 Return to debug level 5.
> 3 Return to level 4.
> 4 Return to debug level 4.
> 5 Return to level 3.
> 6 Return to debug level 3.
> 7 Return to level 2.
> 8 Return to debug level 2.
> 9 Return to level 1.
> 10 Return to debug level 1.
> 11 Return to level 0.
> 12 Return to top loop level 0.
>
> Type :b for backtrace, :c <option number> to proceed, or :? for other
> options
1. Start a fresh lisp.
2. Type (describe '+)
3. Type (describe '+)
4. Become enlightened.
Duane
On Feb 12, 8:37 am, Slobodan Blazeski <·················@gmail.com>
wrote:
> I assign the function to symbol-value but sometimes works sometimes
> doesn't. What I don't understand?
> (setq plus #'+)
> #<Function + 20A6521A>
>
> (mapcar plus '(1 2) '( 3 4))
> (4 6)
>
> (setq + #'+)
> #<Function + 20A6521A>
> CL-USER 14 : 5 > (mapcar plus '(1 2) '( 3 4))
> (4 6)
>
> (mapcar + '(1 2) '( 3 4))
> Error: Argument to apply/funcall is not a function: (MAPCAR PLUS
> (QUOTE (1 2)) (QUOTE (3 4))).
> 1 (abort) Return to level 5.
> 2 Return to debug level 5.
Bad choice of variable-name, + has a special semantics, see
http://www.lispworks.com/documentation/HyperSpec/Body/v_pl_plp.htm.
With sbcl one even gets a nicer error message:
The value (SETQ + #'+) is not of type (OR FUNCTION SYMBOL).
salu2
Karsten
On Feb 12, 9:19 am, karsten <·············@gmail.com> wrote:
> On Feb 12, 8:37 am, Slobodan Blazeski <·················@gmail.com>
> wrote:
>
>
>
>
>
> > I assign the function to symbol-value but sometimes works sometimes
> > doesn't. What I don't understand?
> > (setq plus #'+)
> > #<Function + 20A6521A>
>
> > (mapcar plus '(1 2) '( 3 4))
> > (4 6)
>
> > (setq + #'+)
> > #<Function + 20A6521A>
> > CL-USER 14 : 5 > (mapcar plus '(1 2) '( 3 4))
> > (4 6)
>
> > (mapcar + '(1 2) '( 3 4))
> > Error: Argument to apply/funcall is not a function: (MAPCAR PLUS
> > (QUOTE (1 2)) (QUOTE (3 4))).
> > 1 (abort) Return to level 5.
> > 2 Return to debug level 5.
>
> Bad choice of variable-name, + has a special semantics, seehttp://www.lispworks.com/documentation/HyperSpec/Body/v_pl_plp.htm.
>
> With sbcl one even gets a nicer error message:
> The value (SETQ + #'+) is not of type (OR FUNCTION SYMBOL).
>
> salu2
>
> Karsten
Thanks.
bobi