My WordPress Blog
Trying to figure out some multiprocessing code from last night. As one would expect, the single thread code maxes out a single core and the other three(it’s a dual core HT chip) are very lightly loaded with random background crap. For multiprocessing, the average load per core is in between the peak vs…
I have the lottery project for programming practice, but that would require much more statistics knowledge than I have to come up with the algorithm and to interpret the results. Another I have might not require as much stats knowledge. Possibly some, because it’s looking for correlations, but not nearly as heavy on the numerical…
So, the latest Daily Programmer project I’m working on(I’ll get to finishing the last one, eventually) is this weeks Easy level project, Game of Threes. This one wasn’t complicated, here’s the code. [code language=”python”] def get_diff_from_multiple(n): """ Returns -1, 0, or 1, whichever will add to n to make the sum divisible by 3 """…
So, working on learning Python, I’ll be blogging short bits of code and tutorials to help hone my own understanding- and hopefully someone out there will find it helpful. So, a for loop is used in Python for iterating over a container, and for other loops where you can easily know ahead of time how…
So, I just discovered the Unix tool bc. Given that I’m a Mac guy as much for the Unix as for anything else, this got me interested. bc is a mathematical programming language and interactive calculator. The latter is useful, sometimes I need a calculator, and for what I’m doing that instant, a terminal app…
For instance, I could do this- fun op-(x,y) = x+y This makes the ‘-’ operator do integer addition. Reals? Hah, no subtracting them now! Fails type checking on anything but ints. I can also do: fun op-(x) = ~x; Now, the ‘-’ operator does nothing except spawn error messages wherever it is used. Well, wherever…
(if exp1 then exp2 else exp3) div (if exp4 then exp5 else exp6) Is valid and for at least some problems, is entirely reasonable. I think the key to SML, at least so far… *everything* is an expression. Any complete statement returns a value, and anything that returns a value counts as an expression. Ok,…
Finished the current assignments and lectures for my Programming Languages course on Coursera, so I figured I’d go and do some other stuff in ML. ML is a functional language, very heavy on recursion among other fun differences from imperative and OO languages. Here’s a solution to Project Euler problem 1, summing all multiples of…