From: "Ara.T.Howard" <ahoward / noaa.gov> Subject: Re: Q: Shifting a hash anf and array Date: Tue, 17 Aug 2004 08:33:24 -0600 (MDT) Hi Ara and the other problem solvers, WHOW! (<- that's describing the best... ;) There was ever a difficulty for me and will ever be: I dont know, what I like most: Ruby or its mailing list people ! :O) Really, not joking! How often I heard: "Open Source? No costs - no hotline ! This can not be serious software for serious software development." According to so called "hotlines" I think, the best what ever could happen to Open Source is NOT HAVEING that kind of hotlines! Tell me ONE commercial product, for what you get THAT much valuable help in THAT short time (less than 12 hours)! Only ONE! :) Ok, back to the arrays'n'hashes.... Three days ago I saw a british film on TV about the decyphering of the Enigma machine in Blechtley Park...FASZINATING! Very good film! What follows was a googling party "in search of the Enigma".... ;) I found a bash script, which implements a lot of different Enigmas and I thought it would be a good opportunity to learn more Ruby to implement the Enigma in Ruby. One of the basic concepts of the Enigma machine are the wheels. Those wheels had 26 input terminals on the one side and 26 output terminals on the other side. Each terminal was representing one letter. The connnection between the front and back terminals were "crossed wired" -- or irregular (right word?). What was put as an "A" on the front came out as (fro example) "Q" on the back. Three or four wheels were packed on one axis. Which each letter input the wheels were rotated one position (I haven't figured out, how exactly this works until now...). That means: "AAA" came out as (for example) "QZF" and not as "QQQ". I thought of implementing the wheels as such not-integer-but-ordered-indexed "arrays". And my question about all this rotating and shiofting stuff was to figure out how to "rotate" my wheel-arrays. There much other stuff to figure out...there was also a "Reflector" (whatever it was used for) and a so called "Steckerboard" ("Stecker" is german for "plug", but every site about the Enigma calls this a "Steckerboard" and "...the code was steckered..." ("connected" or "plugged in" or so in English) OT: If anyone knows a good site with detailed description of the mechanical "inside" and the meachnisms of the different Enigma machines...hu,hu...me! Here, please! :))) Sorry for this longish "book about the Enigma" :))). But I thought it could be interesting. Thank you all for all your help! Ruby.use! Meino > On Tue, 17 Aug 2004, Meino Christian Cramer wrote: > > > Absolutely correct. I was searching for something like "an array > > with indices not being integers but ordered". > > hi meino- > > i have written such a beast: > > ~ > cat a.rb > # > # http://raa.ruby-lang.org/project/arrayfields/ > # > require 'arrayfields' > > fields = %w( zero one two ) > array = [0,1,2] > > array.fields = fields > > p array['zero'] > p array['one'] > p array['two'] > > p array.values_at 'zero', 'one', 'two' > > p array[0] > p array[1] > p array[2] > > p array.values_at 0,1,2 > > array['three'] = 3 # assignment to un-named fields appends > p array.fields > p array['three'] > > ~ > ruby a.rb > 0 > 1 > 2 > [0, 1, 2] > 0 > 1 > 2 > [0, 1, 2] > ["zero", "one", "two", "three"] > 3 > > regards. > > -a > -- > =============================================================================== > | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov > | PHONE :: 303.497.6469 > | A flower falls, even though we love it; > | and a weed grows, even though we do not love it. > | --Dogen > =============================================================================== >