Search found 693 matches

by qbg
Tue Mar 29, 2011 10:59 pm UTC
Forum: Coding
Topic: I want to make a game, for portfolio and $$. Which Language?
Replies: 19
Views: 5590

Re: I want to make a game, for portfolio and $$. Which Langu

I want to make a game. I don't know what language to use, nor the exact type of game (partly because the game I make will depend on the language/what's most practical). I'm a hobbyist coder, and I'm hoping someone will have some suggestions. I want my game to be salable - so a clean interface, poli...
by qbg
Thu Feb 17, 2011 5:34 am UTC
Forum: Coding
Topic: Coding tasks to pick up a new language
Replies: 10
Views: 1703

Re: Coding tasks to pick up a new language

The first thing I wrote in Javascript was the Fibonacci numbers. The second thing I wrote was a script to save the state of a textbox on a web page and restore it. (Both very easy tasks) The third thing I wrote was an optimizing compiler that compiles a variant of Factor to Javascript. You might wan...
by qbg
Thu Feb 10, 2011 6:06 am UTC
Forum: Coding
Topic: C to Java translation
Replies: 3
Views: 1199

Re: C to Java translation

Is there a website or any forums where in I post my C code and get Java code for the same? I need to convert my program to Java. Not that I don't know. But I really don't have time to sit and write the code. So please help! If you don't have the time, but have time in general, pay someone to do it....
by qbg
Sat Jan 15, 2011 6:48 pm UTC
Forum: Coding
Topic: TI Basic Prime Factorer
Replies: 49
Views: 8360

Re: TI Basic Prime Factorer

Why not implement something like Shanks' square forms?
by qbg
Wed Jan 12, 2011 9:40 pm UTC
Forum: Religious Wars
Topic: Parentheses
Replies: 26
Views: 6278

Re: Parentheses

Yakk wrote:

Code: Select all

#define sq(x) (x * x)

Assert( sq(1+1) == 3 )

(In short: you don't understand macros. Stop using them. There are reasons to use macros, but they are dangerous, unstable and rather unrelated to what you wrote above.)

It gets worse:

Code: Select all

int a = 4;
int b = sq(a++);
// What does b contain?
by qbg
Sun Jan 02, 2011 6:36 am UTC
Forum: Computer Science
Topic: Feels type insecure? (informal discussion of opinions)
Replies: 15
Views: 2771

Re: Feels type insecure? (informal discussion of opinions)

Ever get the feeling that something just isn't type safe enough? Sometimes when I'm hacking away at python, I just get the feeling that it lacks a certain something. That I might screw up at some point and get weird run-time errors. Is it a particulus or do you get that feeling too sometimes? In dy...
by qbg
Sat Dec 18, 2010 5:47 am UTC
Forum: Coding
Topic: Similarities between C/C++ and Java
Replies: 24
Views: 5055

Re: Similarities between C/C++ and Java

Another big advantage of Java is the platform. There are many useful classes that are part of the standard, and a large amount of libraries available. JVMs are also very nice pieces of technology.
by qbg
Thu Dec 16, 2010 5:06 am UTC
Forum: Computer Science
Topic: Compiling languages into C
Replies: 9
Views: 3110

Re: Compiling languages into C

Lisp in Small Pieces describes compiling Scheme into C (and a bunch of other stuff).

Closures are merely a structure containing an environment and the code to execute.
by qbg
Mon Sep 27, 2010 6:04 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1777604

Re: Coding: Fleeting Thoughts

So as it turns out, my function for deciding which continued fraction to take input from is broken, and I have no clue of how to fix it. I modified my code so that it alternates input (which is more inefficient than it needs to be), and the hack works well enough that I was able to generate a mandel...
by qbg
Mon Sep 27, 2010 3:46 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1777604

Re: Coding: Fleeting Thoughts

You, sir, name? wrote:You didn't omit the limit on iteration depth by any chance?

Nope; I have the number of iterations capped at 100.

There might be a bug in my code that causes an infinite loop, or demands more terms than necessary. I wonder what switching to rational math would do...
by qbg
Mon Sep 27, 2010 2:53 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1777604

Re: Coding: Fleeting Thoughts

You can do arithmetic on a sequence of continued fraction terms, and make it so that the resulting sequence is lazy, giving what I call "lazy numbers". Lazy numbers are cool. Lets write a mandelbrot set generator that uses them for infinitely precise output! Just think of everything double...
by qbg
Wed Sep 22, 2010 4:34 pm UTC
Forum: Coding
Topic: Scheme String I/O
Replies: 2
Views: 578

Re: Scheme String I/O

According to R6RS, there a get-line function.
by qbg
Sun Aug 29, 2010 11:53 pm UTC
Forum: Coding
Topic: Lots of questions
Replies: 14
Views: 2429

Re: Lots of questions

Watercleave wrote:Last and probably least, how do you generate a random integer in Java?

Code: Select all

import java.util.Random;

Random rnd = new Random();
rnd.nextInt(n);
by qbg
Thu Aug 26, 2010 12:20 am UTC
Forum: Coding
Topic: The C Killer
Replies: 62
Views: 9094

Re: The C Killer

It is built on top of a powerful lisp. Stage 1 of compilation is compiling the lisp source. There are some IR forms that when compiled generates IR and is collected for stage 2. There is a large library of macros and functions that provide useful abstraction over the IR forms, like defining function...
by qbg
Tue Aug 24, 2010 2:11 pm UTC
Forum: Coding
Topic: [Unnecessarily-] Compact coding tricks
Replies: 112
Views: 15516

Re: [Unnecessarily-] Compact coding tricks

Cxo wrote:Ternary operators as l-values?!

Code: Select all

int foo = 42, bar = 43;
(foo > bar ? bar : foo) = 0; // oh god...

Please ignore the black helicopters overhead, and leave your door unlocked...
by qbg
Sun Aug 22, 2010 5:11 am UTC
Forum: Coding
Topic: Some help with Java Generics and duplicating constructors,
Replies: 7
Views: 1020

Re: Some help with Java Generics and duplicating constructor

Ahhhh... okay, thanks! Some of the other things you did there also helped answer some questions before I asked them. I'll try to read some more about the super, I don't know too much about it. (is it just like writing "ArrayList" in this case? Or is it "this", but in the form of...
by qbg
Sun Aug 22, 2010 4:53 am UTC
Forum: Coding
Topic: Some help with Java Generics and duplicating constructors,
Replies: 7
Views: 1020

Re: Some help with Java Generics and duplicating constructor

Random attempt to make code better: import java.util.ArrayList; public class FList<T> extends ArrayList<T> { private static final long serialVersionUID = -3008914159788169428L; public FList(T... items) { super(); for (T i : items) { add(i); } } @SuppressWarnings(&...
by qbg
Sat Aug 21, 2010 3:12 pm UTC
Forum: Coding
Topic: Scheme vs. Common Lisp
Replies: 26
Views: 12812

Re: Scheme vs. Common Lisp

Clojure. It takes good stuff from both CL and Scheme, adds to that yet more goodness, brings you up to the present, and has great interop with the JVM so it has a huge library available to it. As an alternative, what about other languages? I want something that has a powerful macro system like Lisp ...
by qbg
Sat Aug 14, 2010 10:15 pm UTC
Forum: Coding
Topic: How to extend a (really) basic CAS...
Replies: 4
Views: 1151

Re: How to extend a (really) basic CAS...

[list] Now, what do you mean by pattern matching? Giving it a list of integrals, and splitting the expression into parts that are in the list? Each integral would have a pattern that the program tries to match the expression against, and if it succeeds it generates a list bindings for the variables...
by qbg
Sat Aug 14, 2010 7:53 pm UTC
Forum: Coding
Topic: How to extend a (really) basic CAS...
Replies: 4
Views: 1151

Re: How to extend a (really) basic CAS...

Hi everyone! Today , I wrote a program in Java that can take any (1 variable) expression involving addition, subtracting, multiplication, division, trig functions and logs, and can then substitute in a value for x, or return a new expression representing the derivative, or solve it's equality to an...
by qbg
Fri Aug 13, 2010 9:08 pm UTC
Forum: Coding
Topic: Halting problem coding challenge
Replies: 59
Views: 7712

Re: Halting problem coding challenge

coltz(integer n) { if (n % 2 == 0) return coltz(n / 2); else if (n != 1) return 1; else return coltz(3 * n + 1); } call coltz(203948752093847520394875234531415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679...
by qbg
Fri Aug 13, 2010 8:02 pm UTC
Forum: Coding
Topic: Halting problem coding challenge
Replies: 59
Views: 7712

Re: Halting problem coding challenge

Cosmologicon wrote:That's right. How did you do that? Did you factor it, or was it something more clever?

msieve factored it in 5:38.
by qbg
Fri Aug 13, 2010 7:40 pm UTC
Forum: Coding
Topic: Halting problem coding challenge
Replies: 59
Views: 7712

Re: Halting problem coding challenge

A less obvious challenge would be: write a short program which you know (and can prove) whether it will halt, but it's hard for others to figure out. Here's one: dsum = lambda x: x if x < 10 else x % 10 + dsum(x/10) k = 1 N = 2166657360915746838128951533272068977800067378982909602327684068376113843...
by qbg
Thu Aug 12, 2010 3:04 am UTC
Forum: Coding
Topic: What's so great about pypy?
Replies: 3
Views: 901

Re: What's so great about pypy?

sakekasi wrote:I want to know whether or not the stuff on its website is bs.

Why would you think that?
by qbg
Thu Aug 12, 2010 3:03 am UTC
Forum: Coding
Topic: [Unnecessarily-] Compact coding tricks
Replies: 112
Views: 15516

Re: [Unnecessarily-] Compact coding tricks

Ephphatha wrote:
cogman wrote:void swapint(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

That doesn't work for all inputs. Hell, for ints there's no reason not to use a temp variable, it's (usually) only 4 bytes.

And the compiler would probably optimize it to an efficient swap anyways.
by qbg
Wed Aug 11, 2010 4:44 am UTC
Forum: Coding
Topic: Halting problem coding challenge
Replies: 59
Views: 7712

Re: Halting problem coding challenge

Humans can, without a doubt, prove whether or not almost all Turing machines halt or not. In fact, all we need is inductive reasoning, and then it isn't hard to show the pattern will continue to evolve indefinitely / will expire after some time. The only ones I can imagine that we couldn't deduce t...
by qbg
Mon Aug 09, 2010 11:54 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1777604

Re: Coding: Fleeting Thoughts

troyp wrote:So it seems as well as preloading small integers, Python also caches large ones, just like it does with strings.

Who knew?

If Python used fixnums, then that would hold for a much wider range of integers.
by qbg
Mon Aug 09, 2010 12:04 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1777604

Re: Coding: Fleeting Thoughts

I've been thinking about how one might type check dynamically typed languages. Where as type checkers for statically typed languages reject programs if they can't prove that the program has no type errors, my idea currently revolves around the idea of a type checker that only rejects programs if it ...
by qbg
Wed Aug 04, 2010 7:02 pm UTC
Forum: Serious Business
Topic: Biological nature of Information and the Morality of Piracy
Replies: 109
Views: 12643

Re: Biological nature of Information and the Morality of Pir

I was trying to figure out why I dont feel bad for downloading copy righted material. I am a reasonably good person, I wouldn't steal a physical thing, i wouldn't hurt some one, I even feel bad about not feeling bad about piracy. Perhaps humans are (currently) poorly adapt to the idea of ownership ...
by qbg
Sat Jul 31, 2010 3:09 pm UTC
Forum: Coding
Topic: Language 'Types'
Replies: 9
Views: 2244

Re: Language 'Types'

Side note: The distinction between compiled and interpreted languages is not always clear; some are both.

If a language compiles down to JVM/.NET bytecode, then you could call it compiled; if it uses less primitive (as in higher level) techniques, then you could call it interpreted.
by qbg
Thu Jul 29, 2010 4:44 am UTC
Forum: Mathematics
Topic: Poll: How many square numbers do you know?
Replies: 36
Views: 3582

Re: Poll: How many square numbers do you know?

1-12, 16, 19, and 20 are easy for me.

I only remember 19 easily because it is the standard Go board size.
by qbg
Wed Jul 28, 2010 4:41 pm UTC
Forum: Religious Wars
Topic: Is Java is a bad language for beginners?
Replies: 234
Views: 129286

Re: Is Java is a bad language for beginners?

TBH, OOP still feels like a dumb abstraction to me. It's not how code actually runs. If you write in C, getting your hands dirty with pointers and dynamic memory, you get a lot closer to the The Real Thing, and it makes actually understanding CPU & memory architecture a lot easier. C? Running C...
by qbg
Tue Jul 27, 2010 5:58 pm UTC
Forum: Coding
Topic: [Unnecessarily-] Compact coding tricks
Replies: 112
Views: 15516

Re: [Unnecessarily-] Compact coding tricks

Insane: Embedded forth with much of the program being written in manually compressed (i.e. highly factored) forth.
by qbg
Mon Jul 26, 2010 9:51 pm UTC
Forum: Coding
Topic: A Big Ask
Replies: 34
Views: 4864

Re: A Big Ask

Just for fun I ran this through clang++ as it usually has really great error reporting. I commented out the #include <windows.h> line as I'm on Linux. Output (minus the nice colors): blackjack.cpp:45:113: warning: trigraph ignored [-Wtrigraphs] cout<<". Dealer gets: "<<deck[(dealerHand...
by qbg
Mon Jul 26, 2010 9:43 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1777604

Re: Coding: Fleeting Thoughts

Consider the following code from a lazy lisp of mine: (def fibs (append '(0 1) (zip + fibs (rest fibs)))) (nth fibs 5000) Hopefully it should be obvious what it does. zip presents an interesting question: how lazy should it be? Should it reduce the value being supplied to the function or not? If you...
by qbg
Sun Jul 25, 2010 6:17 am UTC
Forum: Coding
Topic: let's face it, I'll never find a perfect language.
Replies: 6
Views: 1654

Re: let's face it, I'll never find a perfect language.

Learn a programmable programming language (like a member of the Lisp family), program it to be closer to your ideal, and then write your programs in that.
by qbg
Sun Jul 25, 2010 6:06 am UTC
Forum: General
Topic: [SAFESPACE] LGBTIQQA Thread - Queer Support!
Replies: 8231
Views: 1282903

Re: [SAFESPACE] LGBTIQQ Thread - Queer Support!

(I'm terrible at naming things) Well, you'd better not get into programming then. :P It's ten years too late for that. :) I hope you appreciate the sheer amount of effort that went into making such a goofy face! Anyway, on the previous note, here's me a year and a half ago. Eesh. Woo hormones, but ...
by qbg
Wed Jul 21, 2010 11:54 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1777604

Re: Coding: Fleeting Thoughts

Vault wrote:Today I realized what's so special about closures!

What led you to this realization?
by qbg
Wed Jul 21, 2010 6:01 am UTC
Forum: General
Topic: [SAFESPACE] LGBTIQQA Thread - Queer Support!
Replies: 8231
Views: 1282903

Re: [SAFESPACE] LGBTIQQ Thread - Queer Support!

I have long wondered how people choose new names for themselves. Anyone care to share? Prior to the use of ultrasound being widespread, it would be simple: ask your parents what their other planned name for you is. These days, though, expectant parents only need to come up with one name for their b...
by qbg
Wed Jul 21, 2010 2:31 am UTC
Forum: Computer Science
Topic: Your best Fibonacci algorithm?
Replies: 24
Views: 11265

Re: You're best Fibonacci algorithm?

skeptical scientist wrote:Both of those take O(log n), which is best possible (since it takes O(log n) time just to read the input).

Isn't the best possible O(n) since the length of the answer grows at O(n)?

Go to advanced search