Maxima encountered a Lisp error: I do not understand what the problem is - draw

I am trying to do an example in wxmaxima
wxplot_size:[1024,768]$
wxanimate_framerate:2$
with_slider_draw(
/* The parameter we want to assign to the slider and all values it can assume */
R,Resistors,
/* The thing we actually want to draw */
key=concat("R=",float(R)," Ohm"),
explicit(
ev(Voltage(R,t)),
t,0,20
),line_type=dots,color=black,
key=concat("R=0.0 Ohm"),
explicit(
ev(Voltage(0,t)),
t,0,20
),
yrange=[-1,1],
grid=true
)$
and I get the following error. Can anybody help me?
Maxima encountered a Lisp error:
Condition in CDR [or a callee]: INTERNAL-SIMPLE-TYPE-ERROR: |$Resistors| is not of type LIST:
Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
Sorry, but I couldn't put it as code
Thanks

Related

Facing problem while performing basic STL vector program

I am trying to implement a basic STL vector program but I am getting an error I can't understand and can't find a convincing solution either.Here is the image of the code
Here is the error:
*no suitable conversion function from "__gnu_cxx::__normal_iterator<int , std::vector<int, std::allocator>>" to "int" exists
Also, if someone can, please explain me the problem too so that I can prevent this in future?
If you look at cppreference, you'll see that max_element returns an iterator to the maximum element in the sequence.
That's not an int; when you try to assign it to an int, it fails, and gives you a message telling exactly why it's failing.

Arduino and STL

I know this has been posted all over the place but I can not find what I need. I have a Arduino project that I must have vector or another way of allocating a dynamic array safely. I am trying to get the "StandardCplusplus" library to compile but I am getting an error
'Starting combiner'
"C:\Eclipse\eclipse\arduinoPlugin\tools\arduino\avr-gcc\4.8.1-arduino5/bin/avr-gcc" -Os -Wl,--gc-sections,--relax -mmcu=atmega2560 -o "D:/Development/MegaTesting/Release/MegaTesting.elf" ./.ino.cpp.o ./libraries/StandardCplusplus/algorithm.cpp.o ./libraries/StandardCplusplus/associative_base.cpp.o ./libraries/StandardCplusplus/bitset.cpp.o ./libraries/StandardCplusplus/char_traits.cpp.o ./libraries/StandardCplusplus/complex.cpp.o ./libraries/StandardCplusplus/del_op.cpp.o ./libraries/StandardCplusplus/del_opnt.cpp.o ./libraries/StandardCplusplus/del_opv.cpp.o ./libraries/StandardCplusplus/del_opvnt.cpp.o ./libraries/StandardCplusplus/deque.cpp.o ./libraries/StandardCplusplus/eh_alloc.cpp.o ./libraries/StandardCplusplus/eh_globals.cpp.o ./libraries/StandardCplusplus/exception.cpp.o ./libraries/StandardCplusplus/fstream.cpp.o ./libraries/StandardCplusplus/func_exception.cpp.o ./libraries/StandardCplusplus/iomanip.cpp.o ./libraries/StandardCplusplus/ios.cpp.o ./libraries/StandardCplusplus/iostream.cpp.o ./libraries/StandardCplusplus/istream.cpp.o ./libraries/StandardCplusplus/iterator.cpp.o ./libraries/StandardCplusplus/limits.cpp.o ./libraries/StandardCplusplus/list.cpp.o ./libraries/StandardCplusplus/locale.cpp.o ./libraries/StandardCplusplus/map.cpp.o ./libraries/StandardCplusplus/new_handler.cpp.o ./libraries/StandardCplusplus/new_op.cpp.o ./libraries/StandardCplusplus/new_opnt.cpp.o ./libraries/StandardCplusplus/new_opv.cpp.o ./libraries/StandardCplusplus/new_opvnt.cpp.o ./libraries/StandardCplusplus/numeric.cpp.o ./libraries/StandardCplusplus/ostream.cpp.o ./libraries/StandardCplusplus/queue.cpp.o ./libraries/StandardCplusplus/set.cpp.o ./libraries/StandardCplusplus/sstream.cpp.o ./libraries/StandardCplusplus/stack.cpp.o ./libraries/StandardCplusplus/stdexcept.cpp.o ./libraries/StandardCplusplus/streambuf.cpp.o ./libraries/StandardCplusplus/string.cpp.o ./libraries/StandardCplusplus/support.cpp.o ./libraries/StandardCplusplus/typeinfo.cpp.o ./libraries/StandardCplusplus/utility.cpp.o ./libraries/StandardCplusplus/valarray.cpp.o ./libraries/StandardCplusplus/vector.cpp.o arduino.ar "-LD:/Development/MegaTesting/Release" -lm
arduino.ar(new.cpp.o): In function `operator new[](unsigned int)':
C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/cores/arduino/new.cpp:26: multiple definition of `operator new[](unsigned int)'
./libraries/StandardCplusplus/new_opv.cpp.o:C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/libraries/StandardCplusplus/new_opv.cpp:24: first defined here
c:/eclipse/eclipse/arduinoplugin/tools/arduino/avr-gcc/4.8.1-arduino5/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
arduino.ar(new.cpp.o): In function `operator new(unsigned int)':
C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/cores/arduino/new.cpp:22: multiple definition of `operator delete[](void*)'
makefile:83: recipe for target 'MegaTesting.elf' failed
./libraries/StandardCplusplus/del_opv.cpp.o:C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/libraries/StandardCplusplus/del_opv.cpp:25: first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [MegaTesting.elf] Error 1
06:23:57 Build Finished (took 21s.666ms)
I have searched here and online and there seems to be a bunch of fixes but none of them work. There was some mention of including a pnew.cpp in one of your files but this file is not in the library anywhere.
All my code contains that I am trying to compile is
#include "StandardCplusplus.h"
#include "Arduino.h"
void setup(void) {
Serial.begin(57600);
}
void loop(void) {
}
There are a couple of versions of this library out there and I have tried the two main forks that I can find and both of them generate this error.
Also I am using Eclipse with the Arduino AVR plugin to compile.
Edit
I thought that commenting out the lines did work until I tried to use a vector. Once I did the StandardCplusplus library got really mad saying that the function new was not defined.
I think that there needs to be something done to the StandardCplusplus library like in new/new_opv delete/delete_opv files? Or is there a better way?
Edit - 2
Alright so I went into the files:
StandardCplusplus/new_opv.h
StandardCplusplus/del_opv.h
And commented out the bodies for the functions and everything seems to be happy. I did a simple test and everything looks like it is working but now I am concerned that I might of removed something that something else in the library might need, can anyone tell me if my changes will hurt anything?
Edit - 3
Well the last fix didn't work so I tried going to another library all together and I am allot closer. I Downloaded this STL-AVR library and had to make a minor edit to vector.h now I am having problems with the pnew.cpp file. Looks like the template is calling a "new" function that is now defined in arduino but if I try to comment out this body I get that it is not defined. I am sure this is some sort of order of the includes or missing one can anyone help?
Those STL like libary versions you have were put together before operator new was added to the Arduino core. Now they are in the core you are getting a multiple definition error.
You can go into your core and comment out the bits causing the multiple definition error.
You can probably just get away with commenting out the function definitions in the .cpp:
C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/cores/arduino/new.cpp
If you still get the errors, also comment out the function declarations in new.h, but you shouldn't need to as multiple declarations are allowed, only definitions must be unique.

Obtaining untyped pointers to procedures

I'd like to be able to obtain untyped pointers to functions/procedures while in {$MODE FPC} so code illustrated by the following example can work instead of getting an "Incompatible types" error, anyone know how?
program Project1;
{$MODE FPC}
{$MODESWITCH POINTERTOPROCVAR ON} // doesn't stop error
{$TYPEDADDRESS OFF} // doesn't stop error
function new_getmem(asize:longint):pointer;
begin
new_getmem:=nil;
end;
var
mem_mgr_new:tmemorymanager;
begin
mem_mgr_new.GetMem:=#new_getmem; // Error: Incompatible types...
pointer(mem_mgr_new.GetMem):=#new_getmem; // both those work but I'd prefer the
mem_mgr_new.GetMem:=pointer(#new_getmem); // clean code of the line that doesn't work
end.
EDIT:
There used to be an answer below that answered this properly, but it went away. The discussion allowed me to find out that both {$MODESWITCH CLASSICPROCVARS ON} and {$MODESWITCH POINTERTOPROCVAR ON} need to be specified for the desired line to compile, but like was explained, this opens up lots of possibilities for errors, so use with care only when necessary.

Invalid method when method is valid

I have just started a new version of my Crysis Wars Server Side Modification called InfinityX. For better management, I have put the functions inside tables as it looks neater and I can group functions together (like Core.PlayerHandle:GetIp(player)), but I have ran into a problem.
The problem is that the specified method to get the players' name, player:GetName() is being seen as an invalid method, when the method actually is completely valid.
I would like to know if using the below structure is causing a problem and if so, how to fix it. This is the first time I've used this structure for functions, but it is already proving easier than the old method I was using.
The Code:
Event =
{
PlayerConnect = function(player)
Msg.All:CenteredConsole("$4Event$8 (Connect)$9: $3"..player:GetName().." on channel "..player.actor:GetChannel());
System.LogAlways(Default.Tag.."Incoming Connect on Channel "..player.actor:GetChannel());
Event:Log("Connect", player);
end;
};
The below code works when I bypass the function and put the code directly where it's needed:
Msg.All:CenteredConsole("$4Event$8 (Connect)$9: $3"..player:GetName().." on channel "..player.actor:GetChannel());
System.LogAlways(Default.Tag.."Incoming Connect on Channel "..player.actor:GetChannel());
The Error:
[Warning] [Lua Error] infinityx/main/core.events.lua:23: attempt to call method 'GetName' (a nil value)
PlayerConnect, (infinityx/main/core.events.lua: 23)
ConnectScript, (infinityx/main/core.main.lua: 52)
OnClientEnteredGame, (scripts/gamerules/instantaction.lua: 511)
(null) (scripts/gamerules/teaminstantaction.lua: 520)
Any clarification would be appreciated.
Thanks :)
Well, as PlayerConnect is inside the table Event, and you are calling with a ":", add self as first arg in the function, like:
PlayerConnect = function(self, player)
Clearly, player in the first block of code is not the same as player in the second block of code. The problem must be that the caller of Event.PlayerConnect is not passing the same value.
To test that your Event.PlayerConnect function works, try this in the same place as your second block of code:
Event.PlayerConnect(player)
That should work as you expect.
So, the problem comes down to how Event.PlayerConnect is called without the second block of code. I'm not familiar with that game engine so I don't know how it is done. Perhaps reviewing the documentation and/or debugging that area would help. If you print(player) or call the equivalent log function in both cases, you should see they are different. If you can't run in a debugger, you can still get a stack trace with print(debug.traceback("Accessing player, who's value is: "..player)). If there is indeed some kind of table-based player object in both cases, you can try comparing their fields to see how they are different. You might need to write a simple dumping function to help with that.

Octave equivalent of "hold all"

There is a nice command in Matlab called hold all, which causes subsequent plot commands to add to the current plot, using subsequent colours from the current colourmap.
But Octave says:
o.exe:248> hold all
error: hold: invalid hold state
error: called from:
error: C:\Programs\Octave\324_gcc440\share\octave\3.2.4\m\plot\hold.m at line 70, column 2
I've been using hold on, but all the lines a blue and similar, and I'm finding I'm spending too much brainpower trying to figure out which is which, rather than focus on understanding the pattern.
I'm looking for a solution that I can just type in, would rather not modify Octave's code or add scripts, for all the obvious reasons. Automatic colourmap rotation ought to have been the default behaviour, so maybe I'm missing something obvious...?
The option hold all already exists in Octave. The problem is that you're using a very old version of Octave. The current version is 3.6.4.