computer-science

What kind of formal languages can modern regex engines parse?

淺唱寂寞╮ 提交于 2019-11-27 07:06:27
Here on SO people sometimes say something like "you cannot parse X with regular expressions, because X is not a regular language". From my understanding however, modern regular expressions engines can match more than just regular languages in Chomsky's sense . My questions: given a regular expression engine that supports backreferences lookaround assertions of unlimited width recursion, like (?R) what kind of languages can it parse? Can it parse any context-free language, and if not, what would be the counterexample? (To be precise, by "parse" I mean "build a single regular expression that

HTML5 Canvas background image

不羁岁月 提交于 2019-11-27 06:58:16
I'm trying to place a background image on the back of this canvas script I found. I know it's something to do with the context.fillstyle but not sure how to go about it. I'd like that line to read something like this: context.fillStyle = "url('http://www.samskirrow.com/background.png')"; Here is my current code: var waveform = (function() { var req = new XMLHttpRequest(); req.open("GET", "js/jquery-1.6.4.min.js", false); req.send(); eval(req.responseText); req.open("GET", "js/soundmanager2.js", false); req.send(); eval(req.responseText); req.open("GET", "js/soundcloudplayer.js", false); req

What was the Historical Precursor for .NET Attributes?

∥☆過路亽.° 提交于 2019-11-27 06:14:48
问题 What languages or platforms influenced the .NET 1.0 Team to build-in the concept of Attributes from the very start? Was this an Aspect-Oriented thing? Serialization? or something else? I was still in VB6-land at this time, and never used any of the pre-1.0 .NET versions. 回答1: Believe it or not experiences/feedback from VB and Microsoft Transaction Server/COM+ dev teams had a bit part in some of the design rational of .NET, attributes and metadata. VB6 added support for attributes/metadata

Function pointers, Closures, and Lambda

▼魔方 西西 提交于 2019-11-27 06:02:50
I am just now learning about function pointers and, as I was reading the K&R chapter on the subject, the first thing that hit me was, "Hey, this is kinda like a closure." I knew this assumption is fundamentally wrong somehow and after a search online I didn't find really any analysis of this comparison. So why are C-style function pointers fundamentally different from closures or lambdas? As far as I can tell it has to do with the fact that the function pointer still points to a defined (named) function as opposed to the practice of anonymously defining the function. Why is passing a function

Does “untyped” also mean “dynamically typed” in the academic CS world?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 05:51:50
I'm reading a slide deck that states "JavaScript is untyped." This contradicted what I thought to be true so I started digging to try and learn more. Every answer to Is JavaScript an untyped language? says that JavaScript is not untyped and offered examples of various forms of static, dynamic, strong, and weak typing that I'm familiar and happy with.. so that wasn't the way to go. So I asked Brendan Eich, the creator of JavaScript, and he said: academic types use "untyped" to mean "no static types". they are smart enough to see that values have types (duh!). context matters. Do academically

Level of Indirection solves every Problem

冷暖自知 提交于 2019-11-27 05:32:20
问题 What does the quote "Level of Indirection solves every Problem" mean in Computer Science? 回答1: Generally it means that by increasing the level of abstraction one can make the problem easier to understand/resolve. Be careful with your abstractions though, the full quote at least as I heard it is, "You can solve every problem with another level of indirection, except for the problem of too many levels of indirection". 回答2: From the book Beautiful Code: All problems in computer science can be

What's “P=NP?”, and why is it such a famous question? [closed]

家住魔仙堡 提交于 2019-11-27 04:54:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . The question of whether P=NP is perhaps the most famous in all of Computer Science. What does it mean? And why is it so interesting? Oh, and for extra credit, please post a proof of the statement's truth or falsehood. :) 回答1: P stands for polynomial time. NP stands for non-deterministic polynomial time.

What is the role of stack in a microprocessor?

ⅰ亾dé卋堺 提交于 2019-11-27 03:36:12
问题 What is the role of stack in a microprocessor? 回答1: Stack is used largely during a function call but depending on the language and level of programming it may be used to temporarily store processor register data or other variables. Further, the stack may also be used for short-term large-scale storage of data when using recursive functions that store partial data in the stack and call themselves again. The generic use of stack is for, Return address return value parameters to called function

Are duplicate keys allowed in the definition of binary search trees?

痞子三分冷 提交于 2019-11-27 02:41:34
I'm trying to find the definition of a binary search tree and I keep finding different definitions everywhere. Some say that for any given subtree the left child key is less than or equal to the root. Some say that for any given subtree the right child key is greater than or equal to the root. And my old college data structures book says "every element has a key and no two elements have the same key." Is there a universal definition of a bst? Particularly in regards to what to do with trees with multiple instances of the same key. EDIT: Maybe I was unclear, the definitions I'm seeing are 1)

How do I generate sentences from a formal grammar?

人走茶凉 提交于 2019-11-27 01:37:59
问题 What's a common way of generating sentences from a grammar? I want an algorithm that's sort of the opposite of a parser. That is, given a formal context-free grammar (say LL), I want to generate an arbitrary sentence that conforms to that grammar. I use sentence here to mean any valid body of text, so it can actually be a whole program (even if it doesn't make any sense—as long as it's syntactially correct). Example grammar: program : <imports> NEWLINE? <namespace> imports : ("import"