@ГригорийПерельман it's called a block. You can pass a block to any method, and your methods can implement it by calling yield to invoke the block, or saving it to a parameter by putting an additional parameter with an &in front of the name
Actually, now that I think about it, I started this parser thingy as the first step in creating a tool that looks for potential golfs in JS code-golf entries
If I were you, I'd have some sort of needle function, where needle("str") returns true if, from the current parsing index, the next characters are s then t then r. If you're not adverse to using regex, you could integrate regex into this needle function. Tho I have no idea how you're rolling this
I should probably write a helper function to strip the first match of a regex off of the current code and return it (e.g. code = "1+2", f(/\d+/) == "1", code == "+2")
I was going to use the babylon-parsed tree, but a) those are a little too complex for me to work with right now, and b) I wanted to try making my own parser
In this challenge, you'll get four different but somewhat related tasks that must be solved in a specific manner. First, I'll explain the tasks, then follows an explanation of how you must solve it.
Your code should for all four tasks take two positive integers as input: n,m, where n<m. All task...
A register and a double-ended stack (i.e., you can "pop" from either the top or the bottom). Operators manipulate the register and the appropriate "top" of the stack, then store the result back in the register.
This is a homework question which I have no idea how to start, hoping for some pointers.
Suppose I have a pair of integers represented in the form of ABBAC + BAC = ACCCD, where each alphabet represents an integer from 0 - 9, write a recursive code which computes the number of integer solutions ...
In honor to the 1995 classic ghost in the shell (of which I'm going to see the remake tonight) I propose a challenge where you create a shell with a ghost in it.
The challenge:
Create a REPL shell that evaluates numerical statements and has a chance of returning the wrong numerical answer betwe...
@MendeleevLemon I just saw Matthew. I asked him if he installed Gentoo yet, he threw a pencil at me and referred to what happened as "Creepy as fuck" and "How the hell did you know I was there"