# All Questions

67,760 questions
Filter by
Sorted by
Tagged with
593 views

### Adding, subtracting, and multiplying a vector by a scalar

Exercise 2.46. A two-dimensional vector v running from the origin to a point can be represented as a pair consisting of an x-coordinate and a y-coordinate. Implement a data abstraction ...
209 views

### Writing a general purpose “split” function (for SICP's imaginary language)

From SICP 2.2.4: The textbook has already defined a function (right-split ...) as follows: ...
2k views

...
809 views

### OpenGL VertexArrayObject class

It seems to play up sometimes and I'm not sure if this is due to the class itself or the way I'm using it. Can someone confirm that this is a 'good' implementation of a ...
59k views

### JAXB XJC code generation - adding @XmlRootElement and Joda DateTime

Here's an interesting scenario that I encountered the other day. I did eventually reach a solution on my own. However, I'd welcome any comments and better approaches. The requirements I want to ...
2k views

### Eight-queens puzzle

Figure 2.8: A solution to the eight-queens puzzle. The eight-queens puzzle'' asks how to place eight queens on a chessboard so that no queen is in check from any other (i.e., no two ...
898 views

### How would I unit test a method that gets data from an RSS feed?

I have a method that gets an RSS feed using LINQ to XML and returns a collection of an object that grabs only the data I need. There's really only one other method in the class I'm concerned about ...
978 views

### Newbie Map/Reduce word frequency counter

I present you my first ever module to learn some Erlang awaiting your scrutiny . It does a word frequency count using map/reduce . I'm an Erlang noob, so I would very much like feedback about: ...
5k views

### Linux backup script in Python

I've written a backup script to make a backup of the latest modified files in 12 hours. Basically, it searches two directories for modified files (statically coded) then the ...
365 views

### Is ToEnumerable<T> for multiple items a good practice?

In the similar vein as ToIEnumerable and FromSingleItem Is this a good improvement for making lists on the fly? ...
188 views

...
398 views

### Lists' intersection keeping elements' order

I could use the function Intersection, but it returns a sorted list. That's why I have to do my own, but it looks too big. I hope it could be done shorter. ...
567 views

### Formatting a possibly nil value as hours and minutes

This might be a bit silly because there are like a thousand ways to do this, but I'm struggling to come up with one that I like. I feel like this should fit in one line, but I don't like re-using ...
556 views

### Refactor for using ChannelFactory

I use VS 2008 and .NET 3.5 I have this code using CustomChannelFactory and Proxy ServiceReference. I would like refactor using lambdas, Action, ... any suggestions ? ...
912 views

### Find all distinct triples less than N that sum to S

Exercise 2.41. Write a procedure to find all ordered triples of distinct positive integers i, j, and k less than or equal to a given integer n that sum to a given integer s. ...
317 views

### Parse the phone balance from the operator site

How can I write this code better? ...
306 views

### Defining a unique-pairs procedure

From the section called Nested Mappings Exercise 2.40 Define a procedure unique-pairs that, given an integer n, generates the sequence of pairs (...
3k views

### Accessing the only element of Java ResultSet

Does this code look OK? ...
3k views

### C++ critical section with timeout

NOTE: My implementation is based on codeproject article by Vladislav Gelfer. Based on valdok's codes, I rewrote the critical section class. The difference is that my implementation integrated ...
476 views

I'm trying to speed up the following code for summing doubles with full precision, based on a Python recipe from Raymond Hettinger. Any thoughts on how to make this go faster? ...
558 views

### LISP-like list class

So, here's my code: ...
771 views

...
4k views

### Small C++ Boost extension based on boost::property_tree

This is a small extension based on a boost::property_tree, which supports arbitrary values for the properties and appropriate serialization. It can be used as an ...
657 views

### Intersection-detection algorithm

This is an intersection-detection algorithm I developed as an alternative method to the one developed for my coursework. I won't post some of the other functions as they are used in the coursework too,...
943 views

### Cleaning up a multi-model view in Rails3

I'm new to rails and have built a multi-model form. It's working, but some of the code doesn't feel right. The model code is below. I'm using Devise for my user authentication: ...
2k views

### Reverse in terms of fold-right and fold-left

Exercise 2.39 Complete the following definitions of reverse (exercise 2.18) in terms of fold-right and fold-left from exercise 2.38: ...
5k views

### Matrix multiplication and dot-product

Exercise 2.37. Suppose we represent vectors v = (vi) as sequences of numbers, and matrices m = (mij) as sequences of vectors (the rows of the matrix). For example, the matrix is ...
625 views

### Review request: My App Engine library (python)

UPDATE: I didn't write the library pasted below I just make use of it. I'm unable to paste the part I wrote here because the message exceeds 30k characters when I try to do so. I have been working ...
542 views

### Is this the way to use HibernateCompositeUser type for handling localized contents?

I am trying to use HibernateCompositeUser type to handle i18n specific data in my application. I am trying to use the below approach. I have a table named ...
397 views

### Cart Class feedback

I have written a cart Class, it use session to store data. Is the code well implemented or could been better? You can rewrite my code if you can. Each item have a number of options with price Each ...
458 views

### Redefine count-leaves as an accumulation

Exercise 2.35. Redefine count-leaves from section 2.2.2 as an accumulation: ...
904 views

### Approach to programmatically building hierarchical GUI components

At work I am developing an application using hand-coded Swing, and I've found that I have an easier time reading, writing, and maintaining hierarchical component creation using code blocks like: <...
1k views

### XML settings implementation

I'm trying to figure out how to do this more dynamically. Right now I save each and every form field individually/manually. I would love to maybe have some kind of master form list that I could loop ...
3k views

### Simple clock view model

I have been trying to wrap my head around MVVM for the last week or more and still struggling a bit. I have watched Jason Dolingers MVVM video and gone through Reed Copsey lessons and still find ...
982 views

I don't want anything to execute if any preceding step fails: ...
1k views

### What’s your opinion on a Throw() method?

Lately I seem to run into a situation very frequently where I want to write something like the following: ...
8k views

### Searching a sequence for a pattern

I have written the following tiny extension method to help me when I'm working with sequences in which I have to find a pattern. ...
3k views

### Finding the k-th element in a BST

Given a Binary Search Tree, determine its k-th element in inorder traversal. Here's my node structure: ...
1k views

### Spherical Voronoi diagram, binary splitting approach [closed]

EDIT: My code DOES not work, see https://gis.stackexchange.com/questions/294380/if-rectangle-corner-points-have-same-nearest-neighbor-does-whole-interior Given 5 (currently hardcoded) cities, this ...
1k views

I need to figure out the best way to deal with memory pre-allocation Below is pseudo-code for what I am doing now, and it seems to be working fine. I am sure there is a better way to do this, I ...
1k views

### Abstract tree-map function

Exercise 2.31. Abstract your answer to exercise 2.30 to produce a procedure tree-map with the property that square-tree could be defined as ...
375 views

### Square-tree using maps and recursion

Define a procedure square-tree analogous to the square-list procedure of exercise 2.21. That is, square-list should behave as follows: ...
3k views

### Composite and Visitor patterns for tree-based survey functionality in C#

I have written some survey functionality for a project. Basically, a generic survey form that can be composed of sections and questions. I have a Survey class, <...
462 views

### The first major app CMS writen

I am looking for a suggestion or advises about some code I have written. I build an online application about 3 month ago the app registers new buildings including description names and so on. The app ...
568 views

### Are these endless if statements a bad pattern?

I'm only asking because almost the entire code base I've inherited here, in C# and PHP, looks like this: ...
304 views

### Interpreter framework for writing Scheme-like interpreters in < 60 loc

I wrote this interpreter a little while ago and was hoping I could get some comments/criticisms. It it somewhat similar to the "languages as libraries" concept of Racket, though obviously with less ...
227 views

### Is it okay to 'abuse' re-assignment? [closed]

Because I don't like using \ to break long lines (to comply with PEP8), I tend to do something like this: ...
896 views

### Get distinct of two columns

I want to get distinct of two columns from an SQL table. Can I optimize this query? ...