Coffeescript unmatched outdent error - coffeescript

I'm getting the error SyntaxError: Unmatched OUTDENT on line 9 when I try to compile the following coffeescript code. I'm not sure what I'm doing wrong. the indentation seems to be right, and I have everything where I want it.
row_possibilities = (grid) ->
for rows in [0..8] by 1
for columns in [0..8] by 1
if(Array.isArray(grid[rows][columns])
for possible_val in grid[rows][columns] by 1
grid = unique_row_possibility(grid, rows, columns, possible_val)
if(Array.isArray(grid[rows][columns]) == false)
break
return grid
What the code is supposed to do is run the three for loops and breaks the innermost for loop if a certain condition happens.
After all the for loops run. I want to return the variable grid. I've double checked the spacing, and I tried it out on repl.it, but I can't figure it out.

A bit tough to see but it appears that you are missing a closing parenthesis on line 4:
if(Array.isArray(grid[rows][columns])
In general, for this particular error, the problem will almost always lie with indention or unbalanced parenthesis or brackets/braces.

Related

Neovim remap for vscode for commenting doesn't work

This is my current code
map z, <Cmd>call VSCodeNotifyRange('editor.action.commentLine', getline('.'), getline('.') + v:count1, 1)<CR>
Usage of VSCodeNotifyRange used as explained in the Neovim extension's readme:
What I'm trying to do: I pass a number to the remap, for example 5z,
The current line and four next lines are selected in vscode, and then commented out
What's happening: nothing gets commented out, and I get jumped to the line I specified the number to
So when I use 5z, I end up on line 5 (absolute). When I use 10z, I end up on line 10, and so on
I imagine this is a syntax issue, any help would be appreciated

Why would a white space change the meaning of a sentence in auto hotkey?

Recently I noticed a problem that it seems when I call a function with a white space included, the function call won't work correctly.Example:
while true
{
tooltip, % getkeystate ("lbutton","p")
;tooltip, % getkeystate("lbutton","p")
}
return
the code commented works correctly showing 1 or 0 ,but the former one always shows "lbutton", which confused me a lot, I wonder:
1.What causes the difference?
2.What is the syntax of the former one?Why would it return the key name?
3.When would a white space affect the meaning of a sentence?
It is because in the first one, the tooltip evaluates the expression which in this case starts with the empty variable getkeystate and then returns the quoted string lbutton so that is what the tootltip shows.
The second one evaluates a function getkeystate(parameters) to put in the tooltip.

VSCode: order problems top to bottom rather than errors first, then warnings

I use the command: editor.action.marker.next and editor.action.marker.prev to move between errors in my code. However, instead of moving to the closest "problem", it moves to the "error" first and then the "warnings". I want to remove this ordering so that the commands move to closest "problem"
1 _ // -> cursor position
2 const package = require('package') // -> warning - missing semicolon
3 const badPackage require('bad-package // -> error
If I were to run marker.next in the above code with my cursor at line 1 I would jump to line 3, when I really would prefer to jump to line 2.
Is this possible in VSCode?
It is the default behaviour of coc.nvim which gives me hope.

i have this book called learning python the hard way and i have queries regarding that

my code and the terminal .
file = "ex25.py", line 27
words=sort_sentence(sentence)
IndentationError: unindent does not match any other indentation level
The code I wrote in ex25 is:
def print_first_and_last_sorted(sentence):
words =sort_sentence(sentence)
print_first_word(words)
print_last_word(words)
After you define function with the first line, in the second line you need to use proper indentation or spaces. The standard is 4 spaces (4 space keystrokes) or 1 tab.
def print_first_and_last_sorted(sentence):
words =sort_sentence(sentence) # This line and next should be spaced 4 times with
print_first_word(words) # respect to the above one
print_last_word(words)
Your second line is not indented properly. You can compare it with the next lines. They all should be vertically parallel at their start points.
I can't comment but from both the edit and the original post, therefore I can't tell what the indentation actually is.
Python indentation works like blocks of code, similar to other languages except without the curly braces. For example:
def print_first_and_last_sorted(sentence):
words = sort_sentence(sentence)
print_first_word(words)
print_last_word(words)
You may have mixed up spaces & tabs. From this answer, try searching and replacing to replace them with a few spaces.

Find an unsuppressed line in a large script

I am running a script which is fairly large. In the output screen I get ans = 10.
The problem is that the code is very large and I cannot pin point where this output is coming from.
Are there any tips to find the origin of this output within the MATLAB environment since I prefer not to have a random output on the screen?
In the case of a single script file, you can programmatically invoke mlint to return all warnings in the form of a struct:
L = mlint('my_filename'); % No need for .m at the end
Inspecting the structure you could see the following:
This structure has a field named 'message' which contains various issues, among which is what we're after - 'Terminate statement with semicolon to suppress output (in functions).'. At this stage you can run
find( strcmp({L.message},... % output is not suppressed on purpose
'Terminate statement with semicolon to suppress output (in functions).') )
Then inspect the line numbers that get printed.
Alternatively, if you want to skip the variable editor, or want to inspect a whole folder of .m files, you can run mlintrpt (in the case of a folder) or mlintrpt('plotWithoutOutliers') (in the case of a single file) and get a report in the following form:
As Luis said: look for the mlint error. In code this is shown as an orange shaded = and orange wiggle beneath it; on the scroll bar on the right it shows an orange line which you can hover over to see what the warning is and click on to go to the warning.
Additionally I included the red errors for completion. These will cause your code to be unable to run. Same here, red wiggle + red line on the right.
Last, the square on the top right, by the arrow, will either be green (no problems), orange (warnings, but the code will be able to run usually) or red (code won't be able to run).
Used Dev-iL's answer to create a simple function that will tell you the lines of code that are not suppressed. This way you don't need to inspect the returned lines in the structure L. Example: lines = UnsuppressedLines('isEven.m')
function [lines] = UnsuppressedLines( matlabScript)
l = mlint(matlabScript);
unsuppressedInstances = find( strcmp({l.message},'Terminate statement with semicolon to suppress output (in functions).') )
if isempty(unsuppressedInstances)
fprintf('No unsuppressed lines in script')
lines = [];
else
lines = {l.line};
lines = lines(unsuppressedInstances);
end
end