Tagged Questions
2
votes
0answers
95 views
Best practice and/or cleaning binary/decimal/octal/hex converter (now for floating-point values)
This new code comes from my original converter (without floating-point support): Cleaner and/or more practical code for decimal/binary/hex converter
I've had some trouble implementing floating-point ...
2
votes
3answers
137 views
Cleaner and/or more practical code for decimal/binary/hex converter
I've finally finished my converter and have determined that it works, but I'm trying to make it cleaner and/or more practical (primarily with the switch statements). I could probably put more things ...
0
votes
1answer
69 views
I've finally found a satisfactory way to create classes on JavaScript. Are there any cons to it?
Depending on external OO libraries is really bad, using prototypes/new has some limitations, using only hashes has others. Dealing with classes was always a pain in JavaScript and it didn't help that ...
3
votes
1answer
259 views
Which is better: the short, clever way, or the long, ctrl+c way?
The code below is equivalent. I can see pros and cons for both versions. Which one is better?
Short version:
character.on("key",function(key){
var action = ({
...
2
votes
2answers
243 views
Haskell markov text generator
I'm new to Haskell, and here is my first not-totally-trivial program. It's the first program I tend to write in any language -- a Markov text generator. I'm wondering what I can change to make it more ...
3
votes
1answer
94 views
The eternal dilemma: bar.foo() or foo(bar)?
I was using foo(bar) as it's adopted for functional programming.
console.log(
join(
map(function(row){ return row.join(" "); },
tablify(
...
2
votes
1answer
91 views
Simple and efficient code for finding factors and prime factorization?
I've modified this program many times, but I want to know if this is a good way to perform this task. My first algorithm for finding the factors of a number was pretty slow and horrible (started at ...
1
vote
1answer
86 views
General feedback for my GCD/LCM x86 Intel NASM assembly program
I've already created a similar program in C++ first, and then I decided to try to write it in x86 assembly language (the type of assembly I was taught in college). I've already completed the C++ ...
3
votes
2answers
115 views
How can this this URL Checker be made cleaner?
I have a table full of URLs, some of which will occasionally become invalid. As part of a system I'm writing to go through the links periodically, and test if they are valid (or redirect to valid ...
3
votes
3answers
157 views
Advice on program which calculates scores for predictions of Football scores
I am writing a program which calculates the scores for participants of a small "Football Score Prediction" game.
rules are:
if the match result(win/loss/draw) is predicted correctly: 1 point
if the ...
3
votes
1answer
112 views
Die Roller for command line
I've written a die roller which can be run from the command line. It currently exists as three files, but I'll say later why I'd like to make it four. The files are as follows:
die.py: Defines the ...
1
vote
1answer
110 views
Multiple jQuery events on one element with different functions and target selectors
According to this two questions: [1] and [2]
I need a way to combine these two methods of handling the event attachment in jQuery.
$('selector').on({
mouseenter: function() {},
mouseleave: ...
0
votes
1answer
68 views
Optimize nested enumerate blocks?
Well,
i have 3 nested NSEnumeration loops, used to get the textfields of a custom cell, in a custom table in a custom view in a controller...
How can i change this code to make more readable and more ...
3
votes
1answer
67 views
Python Optimizing/Speeding up the retrieval of values in a large string
I have a string containing around 1 million sets of float/int coords, i.e.:
'5.06433685685, 0.32574574576, 2.3467345584, 1,,,'
They are all in one large string and only the first 3 values are ...
6
votes
3answers
119 views
Placement of Conditionals
I've noticed a tendency towards two styles of conditionally executing methods:
Conditional before the call
def foo(thing)
puts thing
end
if thing
foo(thing)
end
Conditional within the call
...