In Matlab's very old versions, what did "\" stand for in a conditional statement? - matlab

For my thesis work I was suggested to use a related code made in year 2000 on Matlab; when transcribing it I found the next syntax for some if loops:
if \ min(x)>= 0
statement;
end
However it is not valid anymore for recent software's versions. I did some search on Google but using "\" is pretty ambiguous and found nothing out of conditionals. Do you know what does it stand for?

Related

PHP upgrade from 4 to 5 requires changing ereg_replace() and ereg() with delimiters

When running former PHP 4 pages in PHP5 I get Deprectiated errors:
I know there are some back slashes that go in there. (or is it forward slashes?) but the " +" item to replace throws me off.
Function ereg_replace() is deprecated:
$perms = ereg_replace(" +", "&", #trim($tmp[0]));
Now this one below really has my mind bent. Only after wearing out my keyboard G-O-O-G-L-E keys did I take a chance and just paste in some code. I decided to answer this question with the hopes of helping someone as challenged as me. What the heck is a "callback function"? I know, I probably use this stuff all day long in other programming languages. Oh well. I think my anxiety level overclowded my correct selection of a forum to answer my simple beginner questions.
preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead:
$string = preg_replace("/&#([0-9]+)/e","chr('\\1')",$string);
My confusion in other StackOverKnow threads and answers is examples are too elaborate. I think someone (including me) could benefit from someone simply typing in the example fixed in correct sytax. I just don't live around this subject that much and because of the millions of lines of code in this RTF generator I'm having to upgrade I'm scared of the "sprong!" effect: I change something and cascading problems occur and I can never change it back.
We purchased a nifty RTF Generator for our club to generate a Word document from our PHP list of hikes. This is where I am finding the Depreciated errors. Just sayin', someday you might need a Word document created from PHP. Hard to find this stuff and it has worked well for the last 9 years.
The " +" is confusing because double quotes and plus sign made me think it was part of the function, not the input.
$perms = ereg_replace(" +", "&", #trim($tmp[0]));
answer: preg_replace("/ +/", "&", #trim($tmp[0]));
This one had me scratching my head about "what function? there is no function!" until I found this almost obscure example and picked the middle solution:
preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead:
$string = preg_replace("/&#([0-9]+)/e","chr('\\1')",$string);
$string = preg_replace_callback("/&#([0-9]+)/", create_function ('$matches', 'return chr($matches[1]);'),$string);
I found This link with comparsions between Depreciated and Replacement to be very useful.

Stata: c.var1#c.var2 operator invalid version 10.1

I would like to check for moderation with Stata using the interaction # and two continuous variables:
version 10.1: xi: regress ................///
c.var1_m#c.var9_m c.var2_m#c.var9_m c.var3_m#c.var9_m ///
var9_m , vce(robust)
However, it seems that only the newest Stata versions support this command, as I get the following error message:
cvar1_m#c: operator invalid
Does anyone know a way to fix this command as such that it also works with Stata 10.1?
(For example to fix the i. command, I typed in version 10.1: xi: and then it also worked on my older version - does something similar exist for c.?)
What version of Stata are you using? Stata 10.1, it seems.
Factor variables were introduced in Stata 11. Regardless of what version you are using this is documented accessibly (e.g.) here.
The question that then arises is why are you using the prefix version 10.1?
If you are using version 10.1, that prefix is redundant; otherwise, it can at most set the clock back to the syntax of earlier versions. It should be clear that it cannot possibly set it forward to the syntax of later versions.
A more fundamental mix-up is that (a) syntax using xi: as aegis and (b) factor-variable notation are (a) old and (b) new versions of the same idea. They should not be mixed. It may be that this alone is the problem, but experts on either [not me] might wish also to see your complete syntax and/or a reproducible example.
In short, if you are using 10.1, or indeed some earlier version, your only option (other than upgrading your Stata) is to cast your problem in syntax acceptable to xi:.

How to force Rails 4 to use old-style hash syntax

I've just upgraded an old project to Rails 4 and I've just realized that it has upgrade the schema.rb using the new-style hash syntax. I suppose Rails is gonna use this syntax for all its generators.
How can I, friendly, say to Rails that I prefer the old-style syntax for hashes?
schema.rb is created by rake db:migrate command. As per my knowledge, it will be hard to suggest the old-style syntax for hashes to Rails. BUT nothing is impossible, you can play around with rails/activerecord/lib/active_record/schema_dumper.rb file. The only problem is when you upgrade the rails gem next time it will override.
This old-style syntax to new-style syntax for hashes was done in Dump schema using new style hash commit.
I know this is not exactly an answer to your question, but it might help nevertheless.
If you use vim, this will allow you to toggle between the old & new syntax (source):
function! s:RubyHashSyntaxToggle() range
if join(getline(a:firstline, a:lastline)) =~# '=>'
silent! execute a:firstline . ',' . a:lastline . 's/[^{,]*[{,]\?\zs:\([^: ]\+\)\s*=>/\1:/g'
else
silent! execute a:firstline . ',' . a:lastline . 's/[^{,]*[{,]\?\zs\([^: ]\+\):/:\1 =>/g'
endif
endfunction
command! -bar -range RubyHashSyntaxToggle <line1>,<line2>call s:RubyHashSyntaxToggle()
noremap <Leader>rh :RubyHashSyntaxToggle<CR>
At max it will take you 3 keystrokes to get the schema the way you want. It is not automatic, but as a counterpart it will work on any file, not just on the schema.
You could invoke the substitution every time you save a file (I do that to remove extra spaces at the ends of lines).
And if you don't use vim, these regexes probably be adapted to other editors.

How to solve shift/reduce conflicts in parser grammar

I'm learning how to write parsers, and to do so, I'm writing parser for SQL.
Grammar I'm writing is processed by perl Parse::Eyapp module, which is very similar to standard yacc.
When I added support for single-operand operators (not sure what is the correct name - operators like 12!, or ## 'value'), when compiling the grammar to perl, I got:
14 shift/reduce conflicts
I had it also earlier, but I solved it by adding appropriate %left and %right, but this time I'm at loss, since the problem seems to be from conflict between 1-operand operators, and more traditional two-operand ones.
Full grammar is too long to put in here, so I'll just link to it.
To compile it, I use command:
eyapp -m Pg::SQL::Parser::SQL -o SQL.pm SQL.eyp
When running eyapp ... with verbose enabled, I get this output.
So, the question is: how to solve the problem in here?
Aargh. Looks like I misdiagnosed the problem. The real cause of the problem were not unary operators, but cast (expr '::' normal_type).
Adding %left '::' at the end of priority configs solved the problem.
In case you're curious - commit link.

What text editor does most accurate job of syntax highlighting Perl

I know I risk asking a speculative question, however, inspired by this recent question I wonder which editor does the best job of syntax highlighting Perl. Being well aware of the difficulties (impossibilities) of parsing Perl I know there will not be a perfect case. Still I wonder if there is a clear leader in faithful representation.
N.B. I use gedit and it works fine, but with known issues.
Komodo Edit does a good job and also scans your modules (including those installed via CPAN) and does well at generating autocomplete data for them.
I'm a loyal vim user and rarely encounter anything odd with the native syntax.vim, except for these cases (I'll edit in more if/when I find them; others please feel free also):
!!expression is better written !!!!expression (everything after two ! is rendered as a comment quoted string; four ! brings everything back to normal)
m## or s### renders everything after the # as a comment; I usually use {} as a delimiter when avoiding / for leaning toothpick syndrome
some edge cases for $hash{key} where key is not a simple alphanumeric string - although it's safer to enclose such key names in '' anyway so as to not have to look up the exact cases for when a bareword is treated as a key name
I haven't used it, but Padre should be good since it's written in Perl. IIRC It uses PPI for parsing
jEdit...with the tweaks that I have amassed over the years. It's got the most customizable syntax highlighting I've ever seen.
I use Emacs in CPerl mode. I think it does a terrific job, although similar to Ether's answer, it's not perfect. What's more, I usually use Htmlize to publish highlighted code to the web. It's kind of annoying to use fancier forums like this one that do their own syntax highlighting, since it's not really any easier and the results aren't as good.