All Questions

Filter by
Sorted by
Tagged with
2
votes
1answer
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 ...
3
votes
1answer
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: ...
5
votes
2answers
2k views

Small method for saving student attendance

...
5
votes
2answers
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 ...
27
votes
2answers
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 ...
6
votes
3answers
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 ...
2
votes
1answer
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 ...
6
votes
1answer
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: ...
8
votes
2answers
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 ...
5
votes
2answers
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? ...
0
votes
1answer
188 views

Specify table data in code, reference objects

...
5
votes
3answers
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. ...
5
votes
3answers
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 ...
3
votes
1answer
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 ? ...
8
votes
3answers
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. ...
4
votes
1answer
317 views

Parse the phone balance from the operator site

How can I write this code better? ...
1
vote
1answer
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 (...
7
votes
5answers
3k views

Accessing the only element of Java ResultSet

Does this code look OK? ...
8
votes
1answer
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 ...
6
votes
1answer
476 views

Full-precision summation in Haskell

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? ...
4
votes
3answers
558 views

LISP-like list class

So, here's my code: ...
0
votes
1answer
771 views

Formatting some data about some airlines [closed]

...
10
votes
1answer
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 ...
3
votes
1answer
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,...
4
votes
1answer
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: ...
5
votes
2answers
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: ...
5
votes
1answer
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 ...
4
votes
2answers
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 ...
11
votes
1answer
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 ...
6
votes
2answers
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 ...
6
votes
1answer
458 views

Redefine count-leaves as an accumulation

Exercise 2.35. Redefine count-leaves from section 2.2.2 as an accumulation: ...
11
votes
1answer
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: <...
7
votes
2answers
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 ...
6
votes
2answers
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 ...
7
votes
5answers
982 views

Shell script to download and extract a tarball from GitHub

I don't want anything to execute if any preceding step fails: ...
14
votes
5answers
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: ...
11
votes
3answers
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. ...
4
votes
1answer
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: ...
7
votes
1answer
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 ...
2
votes
3answers
1k views

Multi-Threaded Memory Preallocation

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 ...
4
votes
1answer
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 ...
1
vote
1answer
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: ...
11
votes
4answers
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, <...
3
votes
2answers
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 ...
9
votes
3answers
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: ...
3
votes
1answer
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 ...
6
votes
2answers
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: ...
5
votes
3answers
896 views

Get distinct of two columns

I want to get distinct of two columns from an SQL table. Can I optimize this query? ...
0
votes
1answer
1k views

Producing a deep-reverse procedure

Exercise 2.27 Modify your reverse procedure of exercise 2.18 to produce a deep-reverse procedure that takes a list as argument and returns as its value the list with its elements ...
5
votes
1answer
650 views

Implementation of String.prototype.replace

With just a brief look over I can think of a large amount of changes that would improve the clarity but I would love to see how someone else would refactor this mess. Spec Code ...

15 30 50 per page