Inaimathi
  • Member for 11 years
  • Last seen more than a week ago
How bad is this jQuery?
14 votes

This...is pretty bad. But there's no real way to tell how bad it has to be given other constraints. For instance, if this is a JS file meant to affect a page whose HTML you don't have control over, ...

View answer
Sum of squares of two largest of three numbers
Accepted answer
10 votes

Scheme is a lot more functional than Common Lisp. The way you can apply that to this situation is by making more use of passing functions around (to the point that this problem is almost a one-liner). ...

View answer
What is the security issue in this code?
9 votes

Off the top of my head: Those parameters don't seem to be escaped before being stitched into a query (opening up SQL injection attacks) The database seems to be keeping passwords in plaintext rather ...

View answer
ELisp function to allow file renaming in Emacs
Accepted answer
8 votes

Judgment circuits deactivated; you have nothing to fear. I was going to suggest that there must already be a function that you can call to force uniquify a buffer, but M-x apropos RET ^uniq doesn't ...

View answer
My first accumulators
7 votes

Speaking for Scheme over here; looks pretty good. I have precisely three aesthetic quibbles, but you got the essence. Also, whether by accident or intention, you aren't doing the Scheme version ...

View answer
Hidden rows toggle
Accepted answer
6 votes

.toggle() exists and seems to do exactly what you want here.

View answer
Simple web-scraper in Common Lisp (SBCL)
Accepted answer
6 votes

You might want to take a look at defining asdf systems instead of using quicklisp to load dependencies internally. The standard way of doing this is to set up an asd file. Here's a decent walk-...

View answer
Animations with vanilla JS
5 votes

You're repeating code blocks all over the place; you may want to abstract some out. For example, calling something like function animatePxProperty(prop, limit, step, interval){ if(!step) step = 1;...

View answer
Switching tabs, with previous/next arrows, using jQuery
4 votes

Firstly, the obvious: Both .addClass and .removeClass can deal with multiple classes at once, so wherever you have something like $('#div1').removeClass( 'hide' ); ... $('#div1').removeClass( '...

View answer
Finite State Machine code
4 votes

As of your second edit. Ok, yeah now that you've shown how this is supposed to be called, CLOS is definitely the way to go here. Representing an object as a list of closures is less than optimal, if ...

View answer
Calculate the weekday from a date (M-D-Y)
3 votes

If you're allowed to use library functions, split already exists as part of cl-ppcre. There's a pretty rich set of date/time functions in the Lisp core that make this trivial. If it's for learning ...

View answer
Creating a repetitive string in Common Lisp
Accepted answer
3 votes

Not a bad approach. I can see one arguable bug, and have a few style notes on your code though. Lets start with the bug: CL-USER> (defparameter a "test") A CL-USER> (pad-with-string 6 a :from-...

View answer
Critique & improve a file reading routine
3 votes

At first glance, you're looking for loops collect clause. (defun read-sim-file (filename) (let ((file-text-list (split "\\n" (batteries:read-text-file filename)))) (loop for line in file-text-...

View answer
Finite State Machine code
3 votes

Can you comment on what the goal/output of this program is supposed to be? How you're supposed to use it? It looks like make-miner just returns a list of functions, which doesn't sound useful on its ...

View answer
Use Newton's Method to compute sqrt(x)
3 votes

abs is mentioned in R6RS, so I'm inclined to believe that you can treat it as a primitive. The scheme convention is to end predicates with ?, so that should really be almost-equal?

View answer
Finding a cryptoarithmetic solution
Accepted answer
3 votes

Some preliminary notes for now (I'll add later): Whenever you need to write (if n n 2) or (if (not n) 2 n), you can instead write (or n 2). or will take any number of arguments and return either nil ...

View answer
Determine type of triangle in LISP
Accepted answer
3 votes

Much better. You seem to like assignment a bit more than I do, though. You can rewrite that last let as (let* ((a (read-side 1)) (b (read-side 2)) (c (read-side 3)) (triangle-type (classify-triangle ...

View answer
LISP - Modify string
2 votes

First, proper indentation helps a lot. I do appreciate you not putting the closing parens on separate lines though. Thank you. (defun string-to-list (string) (loop for char across string collect ...

View answer
Determine type of triangle in LISP
2 votes

In response to the 4th edit, I was thinking something along the lines of (let* ((a (read-side 1)) (b (read-side 2)) (c (read-side 3)) (triangle-type (classify-triangle a b c)) (article ...

View answer
Sorting numbers in LISP
Accepted answer
2 votes

In response to your follow-up. If you're really keen to keep the final formatting of the result "(~d, ~d, ~d)", you can still do that by formatting a list, you'd just have a slightly more complicated ...

View answer
Sorting numbers in LISP
2 votes

Since you have to use ifs, I won't comment on that other than to say that cond (or, more likely, a recursive call) is probably the right choice here. The loop you use in generate-three is slightly ...

View answer
Determine type of triangle in LISP
2 votes

Keep in mind that every form in lisp returns something. (and foo bar baz) returns nil if foo, bar or baz evaluates to nil, and t if all of them evaluate to non-nil. This means that anywhere you write (...

View answer
Erlang code that generates text output
Accepted answer
1 votes

Erlang does pattern-matching, so anywhere you do function_name(Arg) -> case Arg of foo [foo code] bar [bar code] etc end. or similar, you can instead do ...

View answer
Common Lisp macro: review for code quality & leaky name escaping
1 votes

This is the sort of thing you want to get as many eyes on as possible. My gut tells me that you'd want to break it up into smaller functions, but I'm not entirely sure where I'd cut. Any chance of ...

View answer
How can I improve this PHP MySql Rank generation function?
1 votes

It seems like you're just ordering player_stats by some passed-in column and then going through numbering the result starting at 1. It might be simpler to forget storing explicit rank in your DB, and ...

View answer