computer-science

How do you define an anonymous function in lambda calculus terms (or how can I say some language supports anonymous functions)?

我是研究僧i 提交于 2019-12-04 07:48:15
Does java support in current version of 6 lambda expressions or "anonymous functions"? Is there something I can't do in java that I couldn't do with a programming language supporting lambda expressions? I understand that java is turing complete so you can do "anything" in it. Why couldn't anonymous inner class wrapped functions represent functions as defined in lambda calculus? What actually is an anonymous function and how you can say that some language supports anonymous functions? As I already hinted at with my comment above, the question really hinges on how exactly you define "support".

B-Tree vs Hash Table

一曲冷凌霜 提交于 2019-12-04 07:26:04
问题 In MySQL, an index type is a b-tree, and access an element in a b-tree is in logarithmic amortized time O(log(n)) . On the other hand, accessing an element in a hash table is in O(1) . Why is a hash table not used instead of a b-tree in order to access data inside a database? 回答1: You can only access elements by their primary key in a hashtable. This is faster than with a tree algorithm ( O(1) instead of log(n) ), but you cannot select ranges ( everything in between x and y ). Tree algorithms

Efficient implementation of binary heaps

删除回忆录丶 提交于 2019-12-04 07:25:44
问题 I'm looking for information on how to implement binary heaps efficiently. I feel like there should be a nice article somewhere about implementing heaps efficiently, but I haven't found one. In fact I've been unable to find any resources on the matter of efficient implementation beyond the basics like storing the heap in an array. I'm looking for techniques for making a fast binary heap beyond the ones I describe below. I've already written a C++ implementation that is faster than Microsoft

Does table size affect INSERT performance?

假装没事ソ 提交于 2019-12-04 06:17:53
This is a question just for the sake of asking: Barring all intermediate to advanced topics or techniques (clustered indices, BULK INSERTS, export/import tricks, etc.), does an INSERT take longer the larger a table grows? This assumes that there is only one auto-int column, ID [i.e., all new rows are INSERTED at the bottom, where no memory has to shuffled to accommodate a specific row positioning]. A link to a good "benchmarking MySQL" would be handy. I took Oracle in school, and so far the knowledge has done me little good on SO. Thanks everyone. My experience has been that performance

Is it possible to have regexp that matches all valid regular expressions?

梦想的初衷 提交于 2019-12-04 06:10:45
Is it possible to detect if a given string is valid regular expression, using just regular expressions? Say I have some strings, that may or may not be a valid regular expressions. I'd like to have a regular expression matches those string that correspond to valid regular expression. Is that possible? Or do I have use some higher level grammar (i.e. context free language) to detect this? Does it affect if I am using some extended version of regexps like Perl regexps? If that is possible, what the regexp matching regexp is? No, it is not possible. This is because valid regular expressions

Semaphore solution to reader-writer: order between updating reader count and waiting or signaling on read/write binary semaphore?

橙三吉。 提交于 2019-12-04 05:55:01
问题 From Operating System Concepts In the solution to the first readers–writers problem, the reader processes share the following data structures: semaphore rw mutex = 1; semaphore mutex = 1; int read_count = 0; do { wait(rw_mutex); . . . /* writing is performed */ . . . signal(rw_mutex); } while (true); Figure 5.11 The structure of a writer process. do { wait(mutex); read count++; if (read_count == 1) wait(rw mutex); signal(mutex); . . . /* reading is performed */ . . . wait(mutex); read count--;

What is Big O Notation? [duplicate]

烈酒焚心 提交于 2019-12-04 04:24:27
Possible Duplicate: Plain English explanation of Big O I know Big O notation is used to assess how efficient an algorithm is, but I do not understand how you read Big O notation or what exactly how efficient an algorithm is. Can somebody perhaps explain the basics of Big O notation? Thanks. li.davidm What is a plain English explanation of "Big O" notation? is a good explanation of what Big-O notation is and how to use it. This page looks to explain it pretty clearly to me. Essentially it's a convenient way of quickly and accurately assessing the performance characteristics of an algorithm. Be

how to obtain a single channel value image from HSV image in opencv 2.1?

半腔热情 提交于 2019-12-04 03:17:59
I am a beginner in opencv. I am using opencv v2.1. I have converted an RGB image to HSV image. Now I want to obtain single channels Hue, Value and Saturation separately. What should I do? I have seen similar questions here but No-one answered that. Kindly help. You can access the same way you were accessing for RGB image where 1st channel will be for H, 2nd channel for S and 3rd channel for V. If you are using OpenCV 2.1, you must be using IplImage then, right? like if your HSV image is IplImage *src . IplImage* h = cvCreateImage( cvGetSize(src), IPL_DEPTH_8U, 1 ); IplImage* s = cvCreateImage(

Unexpected token in CSS when editing it in vnext

淺唱寂寞╮ 提交于 2019-12-04 00:29:37
When I try to write some css through Vnext or Webmatrix v2 beta I got error that unxpected token : sometime I change something and got error that unexpected error ; When I try this body { background-color :Aqua; } I wonder all browser (moz,chrome) give me error that "Uncaught SyntaxError: Unexpected token :" Later I save it from vs2010 but i still have error. Can someone tell me where I am doing wrong. The error suggests that you're trying to load your CSS as if it were Javascript. Maybe Vnext is expecting the : to be beside the background-color ? Try this background-color: Aqua 来源: https:/

Representing identifiers using Regular Expression

女生的网名这么多〃 提交于 2019-12-03 22:43:51
The regular definition for recognizing identifiers in C programming language is given by letter -> a|b|...z|A|B|...|Z|_ digit -> 0|1|...|9 identifier -> letter(letter|digit)* This definition will generate identifiers of the form identifier: [_a-zA-Z][_a-zA-Z0-9]* My question now is how do you limit the length of the identifier that can be generated to not more than 31 characters. What changes need to be made in the regular definition or how to write a regular expression to limit it to not more than the specified length. Could anyone please help. Thanks. Oscar Mederos The regular expression you