language-agnostic

How to detect duplicate data?

☆樱花仙子☆ 提交于 2019-12-20 09:19:07
问题 I have got a simple contacts database but I'm having problems with users entering in duplicate data. I have implemented a simple data comparison but unfortunately the duplicated data that is being entered is not exactly the same. For example, names are incorrectly spelled or one person will put in 'Bill Smith' and another will put in 'William Smith' for the same person. So is there some sort of algorithm that can give a percentage for how similar an entry is to another? 回答1: So is there some

Data Structure for Subsequence Queries

六月ゝ 毕业季﹏ 提交于 2019-12-20 09:18:07
问题 In a program I need to efficiently answer queries of the following form: Given a set of strings A and a query string q return all s ∈ A such that q is a subsequence of s For example, given A = {"abcdef", "aaaaaa", "ddca"} and q = "acd" exactly "abcdef" should be returned. The following is what I have considered considered so far: For each possible character, make a sorted list of all string/locations where it appears. For querying interleave the lists of the involved characters, and scan

Where and when to use Lambda?

放肆的年华 提交于 2019-12-20 09:16:25
问题 I am trying to understand why do we really need lambda or proc in ruby (or any other language for that matter)? #method def add a,b c = a+b end #using proc def add_proc a,b f = Proc.new {|x,y| x + y } f.call a,b end #using lambda function def add_lambda a,b f = lambda {|x,y| x + y} f.call a,b end puts add 1,1 puts add_proc 1,2 puts add_lambda 1,3 I can do a simple addition using: 1. normal function def, 2. using proc and 3. using lambda. But why and where use lambda in the real world? Any

How to avoid deadlocks?

我与影子孤独终老i 提交于 2019-12-20 09:11:19
问题 When using multiple threads, shared memory needs to be locked by critical sections. However, using critical sections causes potential deadlocks. How can they be avoided? 回答1: One way is to use a hierarchy of critical sections . If you ensure that a parent critical section is never entered within one of its children, deadlocks cannot happen. The difficulty is to enforce this hierarchy. 回答2: The Related list to the right on this page contains a few links that provides interesting information on

Algorithms for modern hardware?

拜拜、爱过 提交于 2019-12-20 09:06:17
问题 Once again, I find myself with a set of broken assumptions. The article itself is about a 10x performance gain by modifying a proven-optimal algorithm to account for virtual memory: On a modern multi-issue CPU, running at some gigahertz clock frequency, the worst-case loss is almost 10 million instructions per VM page fault. If you are running with a rotating disk, the number is more like 100 million instructions. What good is an O(log2(n)) algorithm if those operations cause page faults and

Determining the intersection of a triangle and a plane

随声附和 提交于 2019-12-20 08:59:52
问题 I have a single triangle and a plane (in 3 dimensional space), How would I calculate the line segment where the two cross, if there is no crossing then I need to detect this case. The end result I'm looking for is two 3 dimensional vectors, which define the start and end points of the line segment. To help you out a little, I have already calculated the intersection ray between the plane of the face, and the plane, I simply need to find the endpoints to clip that ray into a line segment. For

Programmatically extracting slides as images from a PowerPoint presentation (.PPT)

空扰寡人 提交于 2019-12-20 08:59:45
问题 Given a PowerPoint presentation in .ppt format, what is the best way to programmatically and using only open source software extract an image representation (in say .jpg or .png ) of each slide in the presentation? The application will run in a Linux server environment, so installing Microsoft Office or Keynote is not an option. The functionality that I want to achieve programmatically is similar to: Keynote's export functionality ( File > Export... > Pictures > JPEG ) PowerPoint's Save As

How to contribute code back to an Open Source project? [closed]

蹲街弑〆低调 提交于 2019-12-20 08:59:13
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . If you're following an Open Source project and would like to contribute code changes, what will you need to do? 回答1: I would spend time getting to know the people first. Usually they have a IRC chatroom where everyone idles. Spend sometime getting to know the people, study the

How can I improve the subjective speed of my application?

我的梦境 提交于 2019-12-20 08:57:54
问题 Today my co-worker noticed that when adding a decimal place to a progress indicator leads to the impression that the program is running faster than without. (i.e. instead of 1,2,3... it shows 1, 1.2, 1.4, 1.6, ...) I checked it and I was surprised that I got the same impression even though I knew it was faked. That makes me wonder: What other things are there to create the impression of a fast application? Of course the best way is to actually make the application faster, but from an

What do you mean by the expressiveness of a programming language?

风流意气都作罢 提交于 2019-12-20 08:46:47
问题 I see a lot of the word 'expressiveness' when people want to stress one language is better than the other. But I don't see exactly what they mean by it. Is it the verboseness/succinctness? I mean, if one language can write down something shorter than the other, does that mean expressiveness? Please refer to my other question - Article about code density as a measure of programming language power Is it the power of the language? Paul Graham says that one language is more powerful than the