formPalindrome “sun” ⇒ “sunus”
formPalindrome “level” ⇒ “level”
is_palindrome x = x == reverse x
is_palindrome_r x | length x <= 1 = True
| head x == last x = is_palindrome_r . tail. init $ x
| otherwise = False
palindrome :: String -> String
palindrome x
...
I can see a possible performance optimization with declaring 2 arrays and iterating the $fake_widgets only once, but how else can I make the following conditional string building more elegant in Ruby?
pending_coloring = $fake_widgets.select do |widget|
widget[:status] == 'awaiting_coloring' &&...
I've created my first Android drawable, a hourglass shaped image, and I'm curious what can be improved with it. It seems weird having to use 4 paths, but I couldn't get it to work any other way.
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/andr...
Based on the previous question, I have utilized most of the answers.
implement insert_after member fucntion
implement Exception safety
prevent self-assignment in assignment-operator.
implement move-initialization constructor
allowing construction and assignment from a std::initializer_list<T>
...
Curious what people think about this implementation of Conway's Game of Life in Haskell.
{-# LANGUAGE QuasiQuotes #-}
module Test.Conway (
conwayCalculateAge,
conwayStep,
conwayMakeRandom,
conwayMakeRandomIO,
conwayMakeEmpty
) where
import Data.Array.Repa
import ...
I am writing code that creates a hash for a store that has an item, price, and sku. The hash is inserted into an array. I also create another hash based on the sku that holds the amount of inventory for that item. I am new to Ruby and am looking for ways to improve my code.
class SimStore
...
I want to scan the iBeacons in the specific radius.
As a receiver; I am developing iOS application to scan all the iBeacons in the region.
1) Is there any way in iOS that will help to reduce the RSSI/Tx power of Bluetooth so that I can reduce the area of detection?
2) Also being important facto...
this is what i done and everytime i refresh/load the page it adds another key to the database $category_id = ""; $query = $connection->prepare("INSERT INTO categories (category_id) VALUES (?)"); $query->bindValue(1, $category_id); if($query->execute()) { $notice_category_id = $connection->lastInsertId(); } — natluf3 mins ago
@natluf if you have a specific programming issue, feel free to search/ask on Stack Overflow. This conversation is outside the scope of Code Review. — Mat's Mug ♦6 secs ago
I heard goto is bad, so I ask someone in this site if my code is better using goto or other alternative
public FormMain()
{
// start of the apps
Start:
// show login form
FormLogin login = new FormLogin();
DialogResult dr = login.ShowDialog();
//...
@Mast How many list of lists would a linked list of lists list, if a linked list of lists could list list of lists?
@Mast or How many linked lists of linked lists would a linked list of linked lists list, if a linked list of linked lists could link linked lists of linked lists?
I have been programming for a couple months now and really wanted to make my own game. So I chose battle ship due to is simplicity (I learned out how wrong I was >.>) so this is it really. Any feedback would be great. I know one thing I am going to hear about is that it isn't portable due to the ...
I have two different versions of my Binary Search Tree add method below. I was assuming both versions would work, but only Version 2 worked. Version1 add method inserts only the first element. Why is that?
Version 1: BST add method:
public void add(int data){
if(root == null){
ro...
This computes the integer square root for any 0 <= N <= (232 - 1)2 at compile time. This was motivated by the fact that many of the algorithms I found were not able to handle large values of N.
I also just wanted to practice template meta-programming.
The implementation is based on this runtime...
This code creates a singleton event dispatcher. It's called like this:
eventDispatcher = Event()
eventDispatcher.on("event", handler)
eventDispatcher.trigger("event", 5)
I'm wondering if this is "the python way," or if it could be improved? Especially the class, I'm not sure about creating a n...
I have a code project that is designed to identify Matching IP Addresses in two files. In order to accomplish this, I stored the IP addresses in different arrays and now trying to compare. I have encountered several issues thus far:
In my info section, I have to find a number before and after t...
Besides the mentioned direct problem, you have a couple of dangerous conditions lurking in your code. Take a look again - what happens if you put in a negative amount? Try if you feel daring. The reason the compiler was complaining about "static can't access non-static variables" is because the professor probably expects you to create a Purchase object (read the problem statement again!), and modify the values in that (eg, via completedPurchase.tax = .2). Generally speaking, mutable static variables should be avoided. After you get this working, go over to Code Review for more. — Clockwork-Muse8 secs ago
The bug may be somewhere outside of the code you presented. Can you provide a minimal working example? Try to reduce it to a code that would be as short as possible. Chances are that when you try to reduce it, the bug will fix itself, giving you a hint where to look for it. SO is not a code review site. — CygnusX147 secs ago
Just looking at you Main class, you notice some strange things.
Passing an already known instance :
ChessBoard chessBoardView = new ChessBoard(myController);
View myView = new View(myController, chessBoardView);
The ChessBoard holds (normally) an instance of Controller.
The View hold an insta...
I'm looking at this class and I'm confused.
The reason why is that I'm doing web programming so a dialog can be asked on different sessions.
In that case this class is useless.
In stead of holding your ProgressDialog and AlertDialog in your class as static variable, just return them in the metho...
Scenario: I have a main thread which spawns few child threads to do some independent tasks. After each child thread finishes their tasks, the main thread proceeds. The code I have written is working in most of the time. However, in case one of child thread gets blocked, the main thread has to wai...
> All code is written in Java, and there is no need to dive into arcane JavaScript details
Why does everyone have this preconceived notion that JavaScript is hard? Maybe a few years ago, when browser standards were lacking, but now its bliss.. all the shims and polyfills are already done for you
My tooltip works fine, but I need to simplify this code.
var genderSelect = {
getGenderSelect: function () {
if(this.val('Girl')){
$(this).find('#girl-character').show();
$(this).find('#boy-character').hide();
}else if(this.val('Boy')){
$(this).find('#boy-character')...
It's not very clear what you're asking. What is "each placeholder of comboEnums"? If you have some possible ways, then include them. If the code is already working you might do better at Code Review — Jamiecjust now
You have two eggs, with the lowest number of drops. Find the maximum floor of a 100-floor building from which you can drop the egg without it breaking.
I created a function which takes an argument of the floor, and then calculates the answer (since creating the physics engine to actually sim...
when I first learned Python, it didn't even have "+=" operators because Guido thought that was unreadable (or maybe a way too many to modify variables). it's come a long way :p
The implementation of the algorithm which adds two number in string form with arithmetic rules.
var assert = require('assert');
var strAdd = function(lnum, rnum) {
lnum = lnum.split('').reverse();
rnum = rnum.split('').reverse();
var len = Math.max(lnum.length, rnum.length),
acc = 0...
I have created a ViewModel for a Product Edit page because it has specific related entities I need to load - the class currently looks like this:
public class ProductEditView
{
public ProductEditView(Product product)
{
this.ID = product.ID;
this.Code = product.Code;
...
Continuing from your last comment 'drawPlayer is one of the culprits', you use graph for drawing operations. The graph context is a huge bitmap to manipulate since it is as big as the screen:
graph.fillRect(0, 0, screenWidth, screenHeight);
To rotate and translate such a big bitmap costs a lot...
I have a WPF Project which is n-tier architecture and I use context per/call as it has Direct-database and web-service
Sorry a bit long question
Presentation => Business Layer => Data Layer
In datalayer i have UnitOfWork pattern implemented.
Initally i had Static DefaultAccessPoint ...
I have been asked to create a computer program for the clap hill lending library.
The following is what I am expected to do:
Members:
The library keeps basic information about each of its members e.g first name, last name and phone number and also each member is given a unique membership number...
oh, wonderful, a moderator removed a comment about an error the poster then corrected. naturally, like everyone who puts thought into their writing, I don't mind seeing it quietly destroyed. I am a selfless and humble servant of social websites who won't bugger off for an entire year.
I'm not sure how someone can argue that array[index].value is more legible than var object = array[index]; object.value, especially when that object is accessed more than once.