Sunday, July 19, 2015
4Clojure: For the Win
:when (= 1 (rem x 4))]
x)
x is assigned the range of integer values from 0-39. x is finite so the for stops evaluating when x is fully consumed.
On each iteration the remainder of x/4 is compared to 1 and if they are equal the body is evaluated (which is just x).
(for [x (iterate #(+ 4 %) 0)
:let [z (inc x)]
:while (< z 40)]
z)
x is assigned a lazy sequence of all the multiples of 4 (iterate from 0 applying +4 at each step using an anonymous function). x is infinite so the for is terminated with :while
Each iteration of the for symbol z is assigned x+1.
While z is less than 40 the body is evaluated (which is just z) and the for loop terminates when z >= 40.
(for [[x y] (partition 2 (range 20))]
(+ x y))
The range from 0-20 is split into segments of 2 numbers. One segment deconstructed into x and y per iteration of the for. The sequence is finite so the for terminates when the full sequence is consumed.
x and y are added as the body of the for.
Each of these results in the same output (a list of each multiple of 4 incremented by 1 up to 37) just by a different mechanism. For my money the first option is probably the best combination of concise and obvious.
Clojure for macro keywords
The examples
(for [x [1 2 3]
y [1 2 3]
:while (<= x y)
z [1 2 3]]
[x y z])
and
(for [x [1 2 3]
y [1 2 3]
z [1 2 3]
:while (<= x y)]
[x y z])
come close to exposing the difference, but what should really be stated explicitly somewhere is that :while stops attempting to evaluate at the first false result whereas (almost said while there >.> ) :when continues to try to evaluate after the false.
(for [x [1 2 3]
y [1 2 3]
:while (= x y)
z [1 2 3]]
[x y z])
;;([1 1 1] [1 1 2] [1 1 3])
(for [x [1 2 3]
y [1 2 3]
:when (= x y)
z [1 2 3]]
[x y z])
;;([1 1 1] [1 1 2] [1 1 3] [2 2 1] [2 2 2] [2 2 3] [3 3 1] [3 3 2] [3 3 3])
Perhaps I'm dense but this wasn't immediately obvious to me.
Edit: Or perhaps I should have actually read. Example 8 is pretty explicit. >.<
Saturday, June 6, 2015
Fuck Microsoft and their little dog too
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
aka KILLITWITHFIRE
The HabitRPG dev environment uses Vagrant and VirtualBox, which was complaining that VT-x wasn't available and dieing horribly (presumably because it's a 64bit guest). But apparently Hyper-V EATS that part of your CPU so nobody else can use it. Or something. Whatever, don't bore me with the technical details, I just wish someone somewhere had thought to mention the critically important bit that HYPER-V WANTS TO MONOPOLIZE THE PLAYGROUND EQUIPMENT. Anyway. Learned my lesson (I might even remember it next time) and won't be touching Hyper-V ever. Unless by some perverse chance I opt to write something for Windows Phone. Which is incredibly unlikely knowing the debugging will require Hyper-V and thus explicitly ban me from doing a hundred other things. You can pretty much forget about that.
Now the vagrant guest is coming up and, with any luck, the VM I had decided was going to need to be wiped might actually be usable again. GAH, I was just starting to think MS gave a shit about computing in general, what with Community VS and free (sorta) Windows 10 upgrades.
Wednesday, April 1, 2015
Cancer
Friday, March 20, 2015
The right to be...
In response to http://intelligencesquaredus.org/debates/past-debates/item/1252-the-u-s-should-adopt-the-right-to-be-forgotten-online
There is no right to be forgotten. That's a misapprehension of the root point. There is instead a right to be understood.
Every story discussed in support of the motion points to the every-human wanting to be understood as what they are, not what they were or what someone else believes them to be.
Every story posed against the motion points equally to a public need to understand who someone is now. The stifling of negative information about public figures being prominent.
So I propose that the motion is simply broken. We should instead be discussing a right to be understood and processes that can express and reinforce that right. Frankly, I don't believe any government is the proper party for that. Law is not, cannot reasonably be, flexible enough for that and so it must come to the individual's interaction with the world that expresses the right. Perhaps sadly there are many individuals with greater leverage in their interactions that don't seem interested in understanding anyone outside their circles.
Tuesday, January 27, 2015
Problem analysis
http://discourse.codenewbie.org/t/coding-exercise-problem-breakdown/618
- Check front door lock.
- If locked, unlock.
- Open front door.
- Until distance to car door = 0, walk toward car door (I'm deliberately ignoring pathing concerns, my car door is basically straight outside my front door)
- Check car door.
- If locked, unlock
- Open car door.
- Sit down in driver seat sideways.
- Juggle lunch, backpack, etc into passenger seat (this sort of crap is why robots tend to look so clumsy, just try and create an algorithm for how your arms move doing that, never mind controlling your balance through it all, your brain really is amazing)
- Pull feet into car.
- Close car door.
- Insert key into ignition.
- Turn key.
Tuesday, January 13, 2015
Code Combet + Firefox = win
It's nearly unplayable in Chrome (which surprised me), it's a lot better in IE (which floored me), but it's smooth as silk in FF. Well, aside from slowing down a bit as the thang count increases.
Also, in IE my solution to one of the levels locks up every time I submit it even though it runs fine in the 'debug environment'. In FF? Works like a charm. Go figure. >.> FF just earned a spot back on my computer.
Sunday, January 11, 2015
Certainty
If you are certain of something then that is something that you must do your utmost to inject doubt into. Examine under the light of many worlds, consider it as the ancient Persian would both drunk and sober, include as many more altered states as your lifestyle allows, consider whether you would believe the same if your moral basis were built upon something else. Perform experiments, physical or social as necessary, to test your understanding and the veracity of your certainty and keep notes. Make it impossible for yourself to ignore the edges of your certainty where logic or fact tells you otherwise. Because once you refuse to allow yourself to see one small facet of reality you begin to blind yourself to all of it. And thence, by all measures of psychiatry, lies madness.
I have yet to find evidence that certainty in any thing does more good than harm. However while there are truths that lack contrary evidence there are no truths that merit certainty. I accept even my initial statement in this post as a poison, it poisons my ability to make statements unambiguously and it poisons my ability to trust in the things that people say. Frankly, that may be a good thing in some cases. I accept that one poison regardless but no further. No other certainty will I knowingly accept into my self.
Smart methods can make a developer look stupid.
Well apparently findnearestenemy() only returns hostiles. Duh. But. As a method that makes it painfully specific. I'd much rather have a method that gives me the nearest actor and lets me decide whether it's one I care about or not. Maybe that method comes later.
Saturday, January 10, 2015
CodeCombat take 2
Oh, and they're looking to hire a level designer which for a 'game' like this would be a very particular set of skills. Suggests that they're doing pretty well too. Though, having a good handful of languages implemented (mostly and partially) is generally pretty good.
Having escaped the dungeon it's time to explore the countryside. Onward!
Edit: Correction. There are a ton of bugs in IE as well. For an extremely frustrating example the second level in the forest area requires the leather boots. Only I couldn't buy them because the price was 'undefined.' Which may only be a minor data error but it stymied my progress until I decided to try buying the next upgrade of boots (reinforced or something) which I thankfully already had the gems for. Equally thankfully the game only checks that you have the required methods available on your equipped gear (in this case the moveXY method) rather than checking the gear itself. So that was at least thoughtfully implemented.
And then, of course, I don't know how many times I'd gone in and out of the level in the forest before it the second level stayed unlocked without a refresh. Here's the scenario: Enter level 2. Fiddle with it some and get frustrated at the bugs. Close IE to try it in Chrome. Get sick of it there, and go back to IE. Level 2 is closed. ?!? Hit refresh. Level 2 is back. !?!
Maybe the page is cache-enabled when it shouldn't be? But Chrome didn't have that particular problem. It has different problems. Cumulatively it's getting to be enough to put me right off the game.
Oh, and apparently you can put @attack in a loop in Coffeescript as long as there's some other statement with it. So... yeah.
Monday, January 5, 2015
It's the end of the year as we know it
And now I've discovered that CodeCombat supports Io. Best surprise I've had all year. Might even keep that title through December!
It's marked experimental but I'm always up for a bit of frustration (or I wouldn't be interested in code anyway). Time to test it out!
Edit: Aww, massive letdown. It's not implemented anywhere near fully enough to be playable. Or maybe fun. I mean, basic loop structures aren't in place. So theoretically you might be able to play through (so far everything I've seen could be done purely by hand but I have no idea how long that will hold out) but you certainly won't learn anything useful or even enjoy the experience. Mind, this is only relevant to Io; I haven't looked at any of the other language implementations yet.
Friday, January 2, 2015
Good intentions
Aphorisms about roads to various places are mistaken. If you were focused on your intention then the destination would be in sight and you'd know you were heading the wrong direction. Intention paves nothing as it isn't substantial enough in this existence to do so; intention must be the compass. Actions (even the act of speech) are your paving stones.