[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Fortran2Ruby

Pawel Szymczykowski

11/18/2006 8:02:00 AM

Hi all,

This is kind of silly, but hopefully not too off topic for the list. :)

I made a small contribution to a friend's (food related) blog today
about the 1978 Star Trek Cookbook. The introductory chapter includes a
source code listing of an old fortran program to type and run (on your
PDP-11?). For whatever reason, I took it upon myself to convert it
over to ruby:

http://www.edibleunknown.com/articles/2006/11/17/cooking-with-trek-the-moti...

Ultimately it works just fine, but it didn't come out as cleanly as I
would like. Specifically the part where I had to pad out the arrays
passed to a sprintf string so as not to get a 'too few arguments'
error. If you don't feel like clicking over, here's what I mean:

fmt007 = ' ' * 2 + "\n" * 3 + ' ' * 5 + '%2c' * 20
pad = Array.new(20).fill(20)

puts fmt007 % [ food[1], waffl[3], dish[2], food[12], dish[3],
fryer[2], waffl[13], *pad ]

I wanted to keep it short and as much in the spirit of the original
fortran program as possible, but that *pad hack bothers me. I've
considered using Array#pack instead of the sprintf since the arguments
are much more similar to fortran's format, but I'd lose the field
width and precision control. Can anyone think of a better way? Maybe
even just a prettier way of padding the array.

And before you tell me, yes, yes... I know that ruby's not fortran and
fortan's not ruby and I'm a fool for wasting your time with this. It's
kind of fun for me though, and I know there are a lot of people out
there more clever than me who enjoy a challenge. Is it possible to
write fortran code in ruby?

Thanks!

-Pawel

5 Answers

Hal E. Fulton

11/18/2006 8:32:00 PM

0

Pawel Szymczykowski wrote:
> Hi all,
>
> http://www.edibleunknown.com/articles/2006/11/17/cooking-with-trek-the-moti...

As Zefrem Cochrane is my witness, that is the strangest thing
I have heard of in a week.

> I wanted to keep it short and as much in the spirit of the original
> fortran program as possible, but that *pad hack bothers me. I've
> considered using Array#pack instead of the sprintf since the arguments
> are much more similar to fortran's format, but I'd lose the field
> width and precision control. Can anyone think of a better way? Maybe
> even just a prettier way of padding the array.

I'll have to look at the original and think about this.
Have you considered just fixing all the array handling,
since you're porting anyway?

> And before you tell me, yes, yes... I know that ruby's not fortran and
> fortan's not ruby and I'm a fool for wasting your time with this. It's
> kind of fun for me though, and I know there are a lot of people out
> there more clever than me who enjoy a challenge. Is it possible to
> write fortran code in ruby?

It's possible to write Fortran in any language. ;)

You're not a fool, you're just eccentric... as are many of us here...


Cheers,
Hal

Pawel Szymczykowski

11/18/2006 9:41:00 PM

0

On 11/18/06, Hal Fulton <hal9000@hypermetrics.com> wrote:
> Pawel Szymczykowski wrote:
> > Hi all,
> >
> > http://www.edibleunknown.com/articles/2006/11/17/cooking-with-trek-the-moti...
>
> As Zefrem Cochrane is my witness, that is the strangest thing
> I have heard of in a week.

Glad to have raised an eyebrow. :) Your new book is great by the way!

> I'll have to look at the original and think about this.
> Have you considered just fixing all the array handling,
> since you're porting anyway?

Do you mean for the 0-vs-1 based arrays? I had considered it, but I
kind of wanted to keep the original indexes to keep it looking close
to the original. If I was going to go about it in a sensible way
though, I guess it would just be a series of puts statements though or
at least a more ruby-like obfuscation.

Here's a text version that compiles under f77 by the way:
http://www.edibleunknown.com/fi...

I didn't really know anything about fortran going in, so I had to play
around with the original to see what the result was supposed to be
first.

> It's possible to write Fortran in any language. ;)

Ah yes, I've heard this corollary and it was part of my inspiration.

> You're not a fool, you're just eccentric... as are many of us here...

Thanks!

-Pawel

M. Edward (Ed) Borasky

11/19/2006 2:17:00 AM

0

Hal Fulton wrote:
> It's possible to write Fortran in any language. ;)
But it's harder in Ruby than most of the others. :)

--
M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
http://borasky-research.blo...

If God had meant for carrots to be eaten cooked, He would have given rabbits fire.


Ryan Davis

11/20/2006 4:16:00 PM

0


On Nov 18, 2006, at 12:02 AM, Pawel Szymczykowski wrote:

> I made a small contribution to a friend's (food related) blog today
> about the 1978 Star Trek Cookbook. The introductory chapter includes a
> source code listing of an old fortran program to type and run (on your
> PDP-11?). For whatever reason, I took it upon myself to convert it
> over to ruby:
>
> http://www.edibleunknown.com/articles/2006/11/17/cooking-...
> the-motion-picture

Alternatively, you could have stuck with fortran:

http://blog.zenspider.com/archive...
inlinefortran_100_released.html



Walter Harding

9/27/2010 3:42:00 PM

0


> >> Typical pro-liar:  It demands the abject servitude of women but
> >> insists that it;s not demanding the abject servitude of women.

> >You do know that's hysterical gibberish, don't you?

> You say that women should be forced to provide the use of their bodies
> in order to keep fetuses alive.  You say that they should be forced to
> suffer pain, injury, expense, and risk to their health and lives.
>
> What is that if not abject servitude?

Parenthood. Unless you want to pretend that most pregnancies are
caused by rape, this was a situation the women entered voluntarily.
As my sister would say (in a sing song tone) "if you play, you must
pay."

> >> You pro-liars cannot tell the truth about anything, can you?
>
> >I'm sorry but you believe that pre born children, AKA embryos, can
> >legally be murdered.
>
> That's pro-liar insanity.  It's as ridiculous as insisting that yhou
> legally murder sperm.

When sperms have brain waves, fingers, and a functioning heart, do get
back to me.

> >> Your ideology is corrupt to the core.
>
> >And yet, you're the one desperate to kill children.
>
> And there is more of the evil hatred that has utterly corrupted the
> anti-abortion ideology.  There is nothing but lie after lie.

Well, the majority of Americans believe these critters are, in fact,
people.

> >> >Are you saying that women AREN'T forcef, by law, to obey endless
> >>> regulations?
>
> >> I'm saying that you're a liar and a stupid asshole.
>
> >Of course.  Very witty.
>
> But you're still not getting it.

Oh, I get it. This nonsense once was taken as wisdom, and now history
is turning against the pro-abortion crowd. You're frustrated because
your best weapons to beat up conservatives with have stopped working.
So, you scream names.

> >Are you saying that women AREN'T forced, by law, to obey endless
> >regulations?

> So according to you, obeying the law is slavery.

I said nothing of the sort. YOU'RE the one who equals pro-life
regulations as slavery, not me. Regulations and laws are part of
doing business in a civilized society - the debate is if the laws are
just. I happen to believe that when you're talking about the lives of
pre-born children vs. the comfort and convenience of the parents, the
children win.

> You really are completely insane.

Again, you're frustrated.