Polyglot "Hello world" in Fortran and Lisp

1

Simple challenge: The code must be both valid Lisp and valid Fortran, and must print out "hello world" in both.

Note: I've sunk about 5 hours into this at this point, I'm not even sure it's possible at this point...

Details:

  • Must be in a single source file.
  • Any version of Fortran and any Lisp are allowed (specify which).
  • Smallest source code (by bytes) satisfying this wins.

CoffeeTableEspresso

Posted 2020-02-26T23:06:28.343

Reputation: 137

Question was closed 2020-02-27T02:27:00.140

Some stuff I've tried so far that might help people: continue is a no-op in Fortran. So continue; ... will just execute ... in Fortran, and just refer to a variable continue in Lisp. (since ; is a line comment in most lisps). I haven't been able to leverage this into anything useful yet though. – CoffeeTableEspresso – 2020-02-26T23:12:15.760

@JoKing yea, you're right. – CoffeeTableEspresso – 2020-02-26T23:25:22.883

2

Possible duplicate of Build a polyglot for Hello World

– pppery – 2020-02-27T01:39:49.710

3Taking a pre-existing challenge and arbitrarily restricting the set of languages in which answers are valid does not make a new, non-duplicate challenge. – pppery – 2020-02-27T01:40:30.647

@pppery I view this as a separate challenge because of how different the syntax is between the two languages. This was also inspired by a harder problem asking for a polyglot between these two specific language, which seemed impossible considering that I wasn't even able to write hello world polyglot between the two. – CoffeeTableEspresso – 2020-02-27T01:44:51.963

The hello world polyglot is not helpful too me since I am specifically looking at polyglots between Lisp and Fortran. (As @DeathIncarnate's solution shows, however, this is not as interesting as I initially thought, since his solution makes it trivial to write a polyglot for the two.) – CoffeeTableEspresso – 2020-02-27T01:46:14.697

4If you would like a specific language answer to a question you can post a bounty on that question. – Post Rock Garf Hunter – 2020-02-27T02:26:45.000

classic stack exchange – CoffeeTableEspresso – 2020-02-27T02:33:38.820

Answers

7

Fortran (GFortran) -ffixed-form, 183 53+12=65 bytes

	;print*,"Hello world!"
	;end
*(print "Hello world!")

Try it online!

Common Lisp, 53 bytes

Try it online!

DeathIncarnate

Posted 2020-02-26T23:06:28.343

Reputation: 916

Damn, that's clever. – CoffeeTableEspresso – 2020-02-26T23:29:14.120

I believe single semi-colons work as well, as well as just end instead of end program – Jo King – 2020-02-26T23:29:52.913

@JoKing Yeah, forgot I'd used full end program because I wanted to see if it would ignore post-end stuff – DeathIncarnate – 2020-02-26T23:35:06.850

You can drop the space after the comma as well I think – CoffeeTableEspresso – 2020-02-26T23:38:57.497

@CoffeeTableEspresso How's that for you? F77 style saving the day. – DeathIncarnate – 2020-02-26T23:51:27.700

@DeathIncarnate damn, that's even shorter than my one where I gave up and used -D... – CoffeeTableEspresso – 2020-02-27T00:05:38.907

@CoffeeTableEspresso Much as I appreciate it, you may want to wait before accepting. It's only been an hour. Better people than me may yet try and blow this out of the water. – DeathIncarnate – 2020-02-27T00:08:07.010

Well, now that this has been closed as duplicate I'll accept it... – CoffeeTableEspresso – 2020-02-27T02:32:47.437