I want to know how I would go about making a 5D list in python? I've tried googling but I haven't found any relevant topics on the subject.
You just use layers of square brackets, like this:
5D = [[[[[]]]]]
Related
I want to go directly to the nth find hit in a document.
For example if I ctrl+f and type in foo and get 109 hits, how can I go directly to foo 42?
I know I can push F3 42 times, but I'm concerned I'd lose count.
Is there some shortcut, like ctrl+g for "Goto Line"? Or some other way?
Example:
1;Cristiano Ronaldo;Portugal;88;121;0.73;'03-;Manchester United, Real Madrid
Sort can help me seperate fiels by the -t ; tag. then -k3,3 can help me select the third field (88). Now let's say I wan to delete this string (88) instead of sorting out, what command can help me? Is there also a command that can help me move the strings from position 88 to position 121 and vice versa?
It sounds crazy to me if I would have to use regular expressions with substitute :s everytime (espcially for moving things) when sort can divide fields by strings
okay so i have a program i am writing , and basically i am going to be taking input for keyboard keys such as left arrow, right arrow, up and down etc and my question is , in what is the best option to scan in these keys so that i can make my program run both in linux and windows
and what am i scanning exactly? am i supposed to scan the ascii values and store them in int? chars? or is it another way to do this ? i have searched the internet and i am finding that the kex values for keyboard scan codes are e0 4b e0 4d e0 48 e0 50
but when i actually scan the values using getchar() and store them into ints i get 4 values for each key pressed namely for example 27 91 67 10 , 27 91 68 10
i understand that each key has press release and other values attached to it , so should i be scanning for the 67 68 etc range?
or is there another way to do this
i am writing the program using c language
In Linux, it seems like you're seeing ANSI escape sequences. They are used by text terminals, and start with the Escape character, which is '\x1b' (decimal 27).
This is probably not what you want, if you want to make something keyboard-controllable in direct, game-like manner you need to use "raw" input. There's plenty of references for that, look at ncurses for instance.
Open a terminal and use the command xev. You can then press any key you want and see its corresponding codes. You can also move and click the mouse to see what happens there.
I use org-mode in emacs to created structured documents but one of the features I'm really interested in and would like to use for other areas are the way links are formatted. Say for example I want to create a link to another location take google for example I could simply write
[[http://www.google.com][To Google]] and as soon as I complete the second square bracket it will change to look like To Google but the underlying structure remains in tact, if I remove the second bracket it simply expands again.
I have downloaded the source code but I cant seem to find where this has been implemented. If anyone knows how it has been achieved I would be very grateful for an explanation. I would imagine It could be replicated with regular expressions but im rather clueless.
Thanks
You can digg from here: C-h f org-activate-bracket-links RET.
C-h f org-toggle-link-display RET and C-h f org-link-display-format RET are also good starting points.
I'm not really looking for syntax help, per say, but approach advice. Here's what I need to do:
I need to read some text in from a file containing moves (this is part of a chess game project) and then print out what move was performed. Here's the example text I'm using for the text file:
EDIT: to clarify, these each represent a move. i.e. RlA1 means white room moved to A1, NlB1 means white knight to B1, etc.
RlA1 NlB1 BlC1 QlD1 KlE1 BlF1 NlG1 RlH1
PlA2 PlB2 PlC2 PlD2 PlE2 PlF2 PlG2 PlH2
RdA8 NdB8 BdC8 QdD8 KdE8 BdF8 NdG8 RdH8
PdA7 PdB7 PdC7 PdD7 PdE7 PdF7 PdG7 PdH7
B1 C3* B2 B3 D8 H4
and here is what should be output for this example input:
A white rook is placed on A1 and a white knight is placed on B1 ... etc
A white pawn ... etc
A black rook ... etc
A black pawn ... etc
The piece on B1 moves to C3 and captures the piece there and the piece on B2 moves to B3 and the piece on D8 moves to H4
Obviously I'll use a toString() method override to print the moves back out, but I need to know how I should go about parsing the input with RegEx to determine what each move is.
Again, not really looking for syntax help so much as advice on how I should approach the problem (Pseudo)
I'm doing this in Java.
First, you just want to split the string into the individual moves. Do this by using your language's string split function.
After doing this, you can parse the individual moves. Note though that chess moves can be quite complex in standard notation, so I'd suggest not trying to mash it all into one regexp. Rather, create helper function such as is_capture, is_castle, is_en_passant, get_moving_piece, and so on.
This depends on the language.
If its a compiled language i would do as tim suggested, split() and parse one letter at a time.
If its command land, then you can use awk for instance to grab each seperate one, space delimited, then parse one letter at a time again.
Since you are writing a Chess Game project, I suggest formatting your moves file in an easier manner to parse. Put all piece placements on one line. On the next line put the moves with a comma separating each move so something like: B1 C3*, B2 B3, D8 H4, etc.
When you are reading in the file, read in the first line and split it on whitespace. Send each of the resulting array elements to a function that parses piece placement.
Read in the next line and split it on comma. Send each of the resulting array elements to a function that parses the moves. Each element will contain the starting and ending place of the piece so you don't have to do as much crazy parsing.