I 'm running into an error and don't know how to fix it.
If I just want to make a vector: kat <- (a, b, c) it trows an error: object 'a' not found.
The workspace is empty, I cleaned it
when I run ls() I get
character(0)
if I make another vector, it always gives me an error always with first element of vector not found.
How is it possible?
Can someone tell me what to do?
Thanks!
Related
I'm getting hundreds of errors like:
foo.thing undefined (type Foo has no field or method thing, but does have Thing)
i.e. the fix is very simple, just change foo.thing to foo.Thing.
Is there a way in Go to tell go build to just go ahead and make these changes in mass?
The GoLand refactoring "Rename a code element" might be a good approach.
VSCode rename symbol could help too.
But Go itself does not have that.
There is a backlog feature request for the compilation error message to be more precise (issue 38965)
Instead of (in this example)
./prog.go:11:7: a.B undefined (type A has no field or method B, but does have b)
./prog.go:12:3: a.s undefined (type A has no field or method s, but does have S)
Having the more prescriptive:
./prog.go:11:7: a.B undefined (type A has no field or method B, but does have field b)
./prog.go:12:3: a.s undefined (type A has no field or method s, but does have method S)
CL 232938, May 2020, still pending.
First question that I've posted here, I'm working on some code for my final on Monday and for some reason I keep getting the following error. Any help would be MASSIVELY appreciated. Thanks!;
The following imagine shows the error in my code, I had switched to 1D math and still can't seem to find the issue
In Maple the global name D has a preassigned value. It is the differential operator. For example,
f := t -> sec(t):
D(f);
t -> sec(t)*tan(t)
The global name D is also protected, ie. you cannot assign another values to it.
And in general it is not a good idea to use the name D like a dummy variable in your code (since is has already been assigned a system procedure, by default). Your example is an (unfortunate) example of strangeness that could ensue.
D * Vector([-3,1]);
Error, (in LinearAlgebra:-Multiply) invalid arguments
You have a couple of alternatives:
1) Use another name instead, such as DD.
2) If you Maple version is recent then you could declare it (once) as a local name for top-level use. For example,
restart;
local D;
D
D * Vector([-3,1]);
[-3 D]
[ ]
[ D ]
If you do declare local D for top-level use then you can still utilize the differential operator by its global name :-D. Eg.
restart;
local D:
f := t -> sec(t):
D(f); # does nothing, since this is the local D
D(f)
:-D(f);
t -> sec(t)*tan(t)
If all that sounds confusing, you'll probably be better off just using another name instead.
The are only a few short symbols with preassigned values or uses, eg. Pi, I, D.
You might want to also have a look at the Help page for Topics initialconstants and trydeclaringlocal .
I develop mathematical model using gurobi solver, in python.
I get the following error while running:
SyntaxError: Generator expression must be parenthesized if not sole argument
My constraint is:
My code is:
for s in S:
m.addConstr(sum(x[s,s0,c,i] for s0 in S0 for c in C for i in D,s!=p) == 1,'C_3')
First of all, everything comes whenever you add that comma: ,s!=p.
I just emulated your code with a model I'm working on, and I obviously got the same error. Look around (e.g. if else in a list comprehension), and you will see that the only mistake you had was that the iterator within the generator wasn't well specified. That means, you had to use an if clause in order to achieve what you wanted:
for s in S:
m.addConstr(
quicksum(x[s,s0,c,i] for s0 in S0 for c in C for i in D if s!=p) == 1,
'C_3_'+str(s) )
By the way, as included in the code, you should use quicksum instead of sum. Furthermore, I would suggest to try changing the order of the iterators; in other words, it's not the same for a computer to enumerate a list of 5 elements 1000 times than to enumerate 5 times a list of 1000 elements, and this is something quite important in Python timing.
As a side note, I got into this question while looking for this:
TypeError: unsupported operand type(s) for +: 'generator' and 'generator'
I know this is kinda stupid question, but I am really despaired now, because I cant find the way to build it. I always get this error
ERROR: call/2: Undefined procedure: main/1
ERROR: However, there are definitions for:
ERROR: main/0
Even though I tried
father(ahmad,samer).
father(ahmad,lolo).
father(ahmad,koko).
grandfather(X,Y):-
father(U,X),
father(Y,U).
main :- father(ahmad, X), writef('%t\n', [X]).
So can someone help me to do it the right way ?
Works just fine for me.
Just type main.
Don't forget the .,otherwise it won't run.
Here is what I got
2 ?- main.
samer
true ;
lolo
true ;
koko
true.
After true type ; instead of pressing the Enter button if you want to show all three names. If you press Enter, only the first name will appear.
From your code I figured out that ahmad is the father,so about the grandfather query, I think I has to be this way:
granfather(X,Y):- father(X,U),father(U,Y).
Because on your father query the father is on the left
I have the following code in prolog to produce a path from one node to other but I can't see my results on the screen. I just get true as an answer. The last variable name doesn't bind to the results:
edge(a,b).
edge(b,d).
edge(b,c).
edge(c,d).
path(A,B,P):-
path_1(A,B,[A],P).
path_1(A,B,P,Path):- last_element(P,S),S=B.
path_1(A,B,P,Path):-
edge(A,X),\+member(X,P),append(P,[X],NewP),
path_1(X,B,NewP,NewP).
last_element([X],X).
last_element([H|T],X):-
last_element(T,X).
I want to get something like: K=[a,b,d] etc.. when I run this code : path(a,d,K)
but its not showing up. only true shows up.
Want to know why. thanks
In your code, Path is not updated in the recursive rule. Change it like this:
path_1(A,B,P,Path):-
edge(A,X),\+member(X,P),append(P,[X],NewP),
path_1(X,B,NewP,P1), append([A], P1, Path).
And it runs well :)
When it is clear that there is an A-X edge and an X-B path, the A-B path should be A + X-B path.
The P variable in path/3 will be instantiated when the Path variable in path_1/4 is instantiated.
However, you never use Path in path_1/4 and therefore the variable does not bind to the results as you observed
Since you use swi-prolog you should get a warning like "Singleton variables: [Path]".
While sometimes it is ok to ignore such a warning, most of the times your code is not going to work as you expected