2

I can seem to figure out why the following command outputs the following

(vector + 1 2)
(vector + 1 2)
=> #((VECTOR + 1 2) 1 2)

Where am I setting +?

sds
  • 58,617
  • 29
  • 161
  • 278
Lime
  • 13,400
  • 11
  • 56
  • 88

1 Answers1

8

You are not setting it, the REPL sets the following variable after evaluating each form you give it:

  • + - the last form
  • - - the current form
  • / - the last form's values as a list
  • * - the last form's primary value ((car /))

This is somewhat similar to the history facility of most modern Unix shells.

PS. An important aspect of your problem is that Common Lisp is Lisp-2, so the symbol + names both a variable and a function.

Community
  • 1
  • 1
sds
  • 58,617
  • 29
  • 161
  • 278
  • Please elaborate. Why is set and when? Or is it a bug? – Lime Oct 08 '15 at 23:18
  • No not particularly. Why? I can't think of something similar happening in unix. – Lime Oct 08 '15 at 23:23
  • Wait...so it's like a history if so do you mind adding an exert for each. – Lime Oct 08 '15 at 23:24
  • If you don't mind adding an exert for each so it is a self contained answer I will gladly accept otherwise as it stands it is not really a self contained answer but merely links to lisp.se – Lime Oct 08 '15 at 23:45
  • 4
    SO cannot be a replacement for RTFM. – sds Oct 09 '15 at 01:59