The following gives some strange "Part" warnings
Clear[f];
f = Function[{x}, x[[1]] == x[[2]]]
However if I execute the second line again, it works without warnings, any idea what's going on?
Are you sure? I don't see any warnings in version 7.0.1:
In[1]:= Clear[f];
f=Function[{x},x[[1]]==x[[2]]]
Out[2]= Function[{x},x[[1]]==x[[2]]]
Related
I was just playing around with interactive ruby.
Near the beginning (line 138), I did
. irb(main):138:0> ['rock','paper','scissors'].index('paper')
=> 1
And that above worked
Then I tried a bunch of lines 139-147 experimenting to get more used to the language
Then I wasn't getting results and I tried some even simpler things I expected would work, 148-154 and didn't get any result.
So it looks like at some point one of my commands might've stopped it from displaying results though i'm not sure what.
I'd like to get it to display the results again. I suppose I could try to exit and go back in but i'd rather a way without doing that,
. irb(main):138:0> ['rock','paper','scissors'].index('paper')
=> 1
irb(main):139:0> a=[1,2,3
irb(main):140:1> a
irb(main):141:1> a=[1.2.3]
irb(main):142:1> a[0]
irb(main):143:1> a(0)
irb(main):144:1> a=[1,2,3]
irb(main):145:1> a(1)
irb(main):146:1> puts a(1)
irb(main):147:1> puts a[1]
irb(main):148:1> a
irb(main):149:1> a=[1,2,3]
irb(main):150:1> a
irb(main):151:1> h={4=>4}
irb(main):152:1> h
irb(main):153:1> puts 6
irb(main):154:1>
If it makes any difference this is my version number and OS is Windows.
C:\blah>ruby -v
ruby 2.1.6p336 (2015-04-13 revision 50298) [i386-mingw32]
C:\blah>
Because of this line here:
irb(main):139:0> a=[1,2,3
You haven't closed off the array with a closing ]. the :1 in irb(main):154:1> makes it clear you're inside a nested expression.
If you enter another ], you'll get a big syntax error because all of what you've entered before it isn't valid array syntax, but then you can move on.
Notice that since late 2019, assignment does not output any more the value in irb.
This is a new case where Interactive Ruby (irb) stop showing result.
NB : you can get the old behavior by setting IRB.conf[:ECHO_ON_ASSIGNMENT] = true in your ~/.irbrc.
I seem to be having an issue with gdb. Let's say I create a conditional breakpoint in a loop over i with the command
break file.cpp:line_no if i==120
everything good, it creates breakpoint 3 and the code breaks when i==120. Now I'm getting a problem at i==495, and I want to re-use the same breakpoint, so I use:
condition 3 if i==495
Well, there I get a "syntax error in expression near `if i==495' So I try:
condition 3 i==495
No more error, and the info for the breakpoint looks promising:
3 breakpoint keep y <MULTIPLE>
stop only if i==495
But it doesn't stop at the breakpoint when the condition is reached. So I start writing this question, and it occurs to me to try:
condition 3 "if i == 495"
and hooray it works. So I guess my questions are: 1. Why the different syntax between the two commands? and 2. Why is the info so confusing? The new info says 'if "if i==495"', but shouldn't that only evaluate to true if 'i==495' evaluates to true?
Your last try is not doing what you think it is doing. When you write:
cond 3 "if i == 495"
the condition is actually the string constant "if i == 495", which is never false. So, the breakpoint stops.
You can see this either by doing print i (for some hits it won't be 495), or by cond 3 "anything goes here!".
The correct syntax was your second attempt:
cond 3 i == 495
I can't say why this isn't triggering for you.
If you are using gdb to debug fortran it might happen that you get a syntax error when trying the reasonable command:
(gdb) b foo.f:10 if i == 0
A syntax error in expression, near `= 0'.
The reason for this is that you must use the old-style fortran syntax (.eq. rather than == and so on) for logical operators:
(gdb) b foo.f:10 if i .eq. 0
Breakpoint 1 at 0x432738: file foo.f, line 10.
I am reading Software foundations book and I came across a command that declares parameters
as implicit:
Arguments nil {X}.
where, for example:
Inductive list (X:Type) : Type :=
| nil : list X
| cons : X -> list X -> list X.
However, whenever I try to execute such commands I get the following message:
Error: No focused proof (No proof-editing in progress).
The same message appears even if I try to compile scripts that come with the book. What could be the problem?
I am using Coq version 8.3pl4 and CoqIDE editor.
I just tried it on my (somewhat old) Coq 8.4 and I don't have any problem with the implicit declaration.
However if I write Argument instead of Arguments (notice the lack of "s"), I get
Error: Unknown command of the non proof-editing mode.
Did you correctly spelled it ?
EDIT: sorry, I miss-read your version. It seems that the Arguments command has been added post 8.4 (it does not appear here but appears here. I advise you update your Coq version if possible, or restrict to using 8.3 Implicit related commands (wild guess: Implicit Arguments foo.)
I have problem with n+k pattern.
I want to enable it, but i don't know how.
I have added {-# LANGUAGE NPlusKPatterns #-} at the beggining of my .hs file, but it didn't work.
Also I try typping in my ghci console -NPlusKPatterns but is just gives me errors.
You need to type
:set -XNPlusKPatterns
in ghci to enable them.
For completeness I'll point out that if you load ghci from the command prompt instead of running winghci, you can load it with ghci -XNPlusKPatterns instead of interactively doing :set -XNPlusKPatterns.
You can check whether it's working by defining an n+k pattern interactively. Here's an example session:
Prelude> let fact 0 = 1; fact (n+1) = (n+1)*fact n in fact 5
<interactive>:8:23: Parse error in pattern: n + 1
Prelude> :set -XNPlusKPatterns
Prelude> let fact 0 = 1; fact (n+1) = (n+1)*fact n in fact 5
120
Good day,
Consider the following:
In[1]:= HoldComplete[With[{line=a},Null]]
Names["`*"]
Attributes/#Names["`*"]
Remove/#Names["`*"]
Out[1]= HoldComplete[With[{line=a},Null]]
Out[2]= {a,line,line$}
Out[3]= {{},{},{Temporary}}
During evaluation of In[1]:= Remove::rmnsm: There are no symbols matching
"line$". >>
Out[4]= {Null,Null,Null}
One can see that Remove::rmnsm message appear although the temporary
Symbol line$ still exists up the that moment. Why this happens?
P.S. I am using Mathematica 7.01. In v.5.2 this message does not appear.
I think what is happening is when you remove the Symbol line then there are no further references to the temporary variable line$ and so it is automagically removed.
In[1]:= HoldComplete[With[{line=a},Null]]
Names["`*"]
Attributes/#Names["`*"]
Out[1]= HoldComplete[With[{line=a},Null]]
Out[2]= {a,line,line$}
Out[3]= {{},{},{Temporary}}
In[4]:= Remove["line"]
In[5]:= Names["`*"]
Out[5]= {a}
This was tested in Mma v8. So maybe the reference counting (or the implementation of localization) has changed slightly since v5?
Note that if you try to remove the temporary symbol first, you get quite an informative warning:
In[6]:= HoldComplete[With[{line=a},Null]]
Names["`*"]
Attributes/#Names["`*"]
Remove/#Reverse#Names["`*"]
Out[6]= HoldComplete[With[{line=a},Null]]
Out[7]= {a,line,line$}
Out[8]= {{},{},{Temporary}}
During evaluation of In[6]:= Remove::relex: Cannot remove lexical symbol
line$ except automatically (when line is removed). >>
Out[9]= {Null,Null,Null}