tehgeekmeister’s blog

March 23, 2008

cocoa, mnemosyne, graded reader group

Filed under: Uncategorized — Tags: , , , , , — tehgeekmeister @ 1:49 pm

i’ve been getting myself familiarized with cocoa in order to, assuming i have the free time, do a proper osx port of mnemosyne, as it currently only works via x11, which i’d like to avoid using when possible (at least in osx).  i like xcode and interface builder so far.  i’ve found that, even if they’re a bit daunting for the beginner (a whole lot of windows pop up for no apparent reason, with no obvious purpose), they cut out a lot of the busy work which would be associated with coding a gui by hand.  this is a nice introduction, and should make it a bit easier when i have to use another gui framework in the future.

i’m porting mnemosyne because i want a simple way to use spaced repetition in my various studies without having to open up vmware just to run mnemosyne.  i’ve wanted a flashcard app that uses spaced repetition for years now, but being that programming is only something i do in my free time, i’ve never quite gotten to the point where i could feasibly do it before.  anyway, it’ll be useful along with the graded reader (more news about that in the next paragraph) for learning languages, and for remembering important formulas and theorems for maths.

james tauber has started a google group and google code project for the graded reader i posted about previously.  this is exciting to me, as it’ll also be very useful to me for language learning, something i’ve long neglected and intend to pick up again shortly.  once his source is in the google code project, i’ll be contributing there as i’m able, however, i’ll likely be making a haskell clone (potentially with some different approaches of my own?  we’ll see.) of both this and mnemosyne, with the aim of integrating them into some sort of an app to aid my language learning.  i’ve wanted to do these things for a long time, but time to program and study is hard to come by for me, and so it’s slow going getting there.

also, thanks to everyone for the suggestions on how to get involved in projects!  i’ll slowly be working on grokking the various projects, looking for things i can fix, and adding documentation as i’m able.  i’ll also be taking a look at lambdabot, since someone mentioned that to me.  if i can help clean it up some, since apparently it’s been neglected, that’d be great.  getting to learn more about programming and haskell and help out the community at the same time is great.

Advertisements

March 18, 2008

how to grok a multi-file project?

Filed under: programming — Tags: , , — tehgeekmeister @ 12:38 am

i’ve decided that my next step in learning haskell and programming will be to get familiarized with and start contributing to a few open source projects.  the ones i’m most interested in and feel the most capable to use/contribute to in any way are yi and happs, and to get started i’ve built and looked around the source of both of them a bit: but i’ve found it very difficult to get oriented in projects of this size.  being that the most complicated things i’ve ever coded are somewhere along the lines of maybench or trivial exercises, i’m not used to figuring out where to start or how to go about understanding larger projects.  so, if anyone out there (hi planet haskell!) has any suggestions for how to get acquainted with a larger project, or can help in any other way, it’d be muchly appreciated.  even better if you’re involved in the development of either yi or happs and would be willing to answer some questions/point me in the right direction until i’m up to speed and able to contribute on my own!

p.s.: one idea i’d had was to attempt to document both projects, seeing as they both are in need of more documentation, and i’d absolutely have to become intricately familiar with the source in order to do that — but the problem remains of how to manage the complexity of a multi-file project, where one starts in order to figure out the whole contraption.

February 8, 2008

checkquick (and hello, planet haskell!)

Filed under: programming — Tags: , , — tehgeekmeister @ 12:51 pm

i’ve just uploaded a preliminary (and hackish) version of checkquick as requested here by eric kow.  it’s already usable, but will likely need a lot more polishing and changes before it reaches any reasonable state.

usage for right now is as follows:

  1. once you’ve checked out the repository, compile Main.hs to your liking.  (i’ll assume it’s compiled to checkquick and is in your $PATH, for simplicity)
  2.  run as follows: checkquick –setup=CMD –cleanup=CMD “CMD1” “CMD2”, where the commands supplied to setup and cleanup should be scripts that respectively setup and cleanup the environment, and CMD1, CMD2 (or more, it will accept an arbitrary number of commands to be timed) are the commands to be timed.

any suggestions or comments are very welcome, but please bear in mind — this is the first time i’ve written any software intended to be used by anyone else before!

January 13, 2008

huh. google knows about me now, go figure.

Filed under: Uncategorized — Tags: , , — tehgeekmeister @ 10:08 pm

apparently submitting that last post to reddit has gotten my previous post to be in the first page of google results for “binary reader“. cool, i’m fine with the inevitable traffic from that.

have finished serge lang’s introduction to linear algebra. a good book on the subject, but i can’t say the subject itself interests me horribly. about to read a first course in calculus by the same author.  calculus should be more interesting.

noticed this post on reddit.  considering, in a few months, or whenever i’m finally up to the challenge, going over the source and attempting to get involved in the development.  contributing to an actual project would be useful and quite the learning experience, but i don’t really have any preference as to what i do or what sort of a project i work on, just that it be something i can actually manage learning on my own.  xmonad may be better for this, potentially — but i don’t use linux, so i’d have to set up a vm just for the purpose.  seems like overkill.  we’ll see.  if anyone has any suggestions of things that need doing or projects that are easier/more useful to start off with, let me know.

aside from that, expect to see a preliminary version of my flowchart app in a post soon, and hopefully in active development after that.  i’ve added in manual state threading, and at this point only need to start writing some code that uses it in order to figure out where the hell i need to go next with it.  also, there’s another grand scheme this fits into, but, well…  that’s another post for when that happens, if ever.

January 12, 2008

better one line binary readers in haskell, thanks to commenters and redditors.

Filed under: programming — Tags: , — tehgeekmeister @ 6:38 pm

update to my previous post on binary readers.

from roconnor:

readBin s = x
where

[(x,"")] = Numeric.readInt 2 (`elem` "01") Char.digitToInt s -- probably the best way of doing it; reinventing what's available in the standard libraries isn't a good thing.

and two from pjdelport:

readBin = foldM (\a d -> (a*2 +) <$> elemIndex d "01") 0 -- as elemIndex evaluates to a Maybe, (<$>) or fmap is necessary to lift the arithmetic section into the Maybe. bonus points for using Maybe instead of error. readBin = (foldl' ((+) . (*2)) 0 <$>) . mapM (`elemIndex` "01") — this version separates “parsing” and summing the values of each bit. otherwise same benefits as the previous versions.

that’s it for now.

January 11, 2008

one line binary reader in haskell

Filed under: computer science, math, programming — Tags: , , — tehgeekmeister @ 4:22 pm

update: apparently this is now in the first page of google results for “binary reader”, so i feel obligated to point out that i posted an update on this, with better versions thanks to commenters both here and on reddit.

i post this in the tradition of pointlessly showing how concisely one’s favorite language can perform a given task. also, i’m slightly proud of this version, as my previous wasn’t nearly as to the point (and wasn’t point free!). so, here it is:

readBin = (`div` 2) . foldl (\x y -> (x + y) * 2) 0 . map (\c -> case c of {‘0’ -> 0; ‘1’ -> 1; _ -> error “Input is not a binary string.”})

previous to this, i was using:

readBin xs = core (map bin xs) 0
where
core [x] n = n + x
core (x:xs) n = core xs ((x + n) * 2)
bin c = case c of {‘0’ -> 0; ‘1’ -> 1; _ -> error ” Input is not a binary string.”}

which, while absolutely equivalent, is overly verbose. now i’ll explain the algorithm for those of you to whom it’s not blindingly obvious (i’m not doing anything tricky or special here, i swear. i’m not that cool.). so, first off, we’re mapping over this string (strings are lists of chars in haskell), and converting each ‘0’ or ‘1’ to the 0 or 1, respectively. also, if we come across something aside from a ‘0’ or ‘1’, we raise an error. once the string is converted to a list of ints, we consume the first value of the list, add it to an accumulator, and multiply that by two. why? because by definition any binary integer has the decimal value of the sum of all the digits, going from right to left, to the nth power, where n is the index starting from zero of the right to left position in the binary representation.

so, wait, if we’re summing and raising to the nth power each digit from right to left, then why are we using a left fold (foldl)? because, in this case, adding the digit to the accumulator (x in the lambda passed to foldl) and then multiplying that times two is exactly equivalent to the previous definition i gave of the decimal value of a binary integer. i’ll leave figuring out exactly why that’s the case to the reader. also, in case you didn’t notice, the fold i’m using in the first definition does one more multiplication by two than the other version, which is why, to reap the benefit of a more elegant, pointfree version, we must divide by two at the end.

the point, on the whole, of this? well, as i already said, it’s pointless. but if there were to be one, it’d be this: damn, haskell is cool. i couldn’t have ever done that in other languages i’ve used. (but i’m sure someone else could. i’m just not that cool.)

p.s.: if anyone finds any flaws with any of what i’ve said here, please take the time to comment — while this algorithm has passed a few test runs, and it seems right intuitively, i’m just not experienced enough to be sure it actually is.

Blog at WordPress.com.