En esta presentación conoceremos detalles de varios lenguajes de programación interesantes, poco populares y diferentes entre sí para invitar al público a ver el código como algo más creativo y a jugar con este para mejorar su desempeño profesional.
Sesión presentada por Zura Guerra en SG Next 2017
11. FLOW-MATIC ·1955
(0) INPUT INVENTORY FILE-A PRICE FILE-B ; OUTPUT PRICED-INV FILE-C UNPRICED-INV
FILE-D ; HSP D .
(1) COMPARE PRODUCT-NO (A) WITH PRODUCT-NO (B) ; IF GREATER GO TO OPERATION 10 ;
IF EQUAL GO TO OPERATION 5 ; OTHERWISE GO TO OPERATION 2 .
(2) TRANSFER A TO D .
(3) WRITE-ITEM D .
(4) JUMP TO OPERATION 8 .
(5) TRANSFER A TO C .
(6) MOVE UNIT-PRICE (B) TO UNIT-PRICE (C) .
(7) WRITE-ITEM C .
(8) READ-ITEM A ; IF END OF DATA GO TO OPERATION 14 .
(9) JUMP TO OPERATION 1 .
(10) READ-ITEM B ; IF END OF DATA GO TO OPERATION 12 .
(11) JUMP TO OPERATION 1 .
(12) SET OPERATION 9 TO GO TO OPERATION 2 .
(13) JUMP TO OPERATION 2 .
(14) TEST PRODUCT-NO (B) AGAINST ZZZZZZZZZZZZ ; IF EQUAL GO TO OPERATION 16 ;
OTHERWISE GO TO OPERATION 15 .
(15) REWIND B .
(16) CLOSE-OUT FILES C ; D .
(17) STOP . (END)
13. SPEAKEASY · 1960
$ suppose you have a very long statement,
$ you can write it on multiple physical lines using "&"
$ at the end of the line to be continued:
:_ the_return_value = this_is_a_function_with many_arguments(argument_1, argument_2, &
:& argument_3, argument_4, argument_5, argument_6)
$ on the other hand, you can collect several short statements
$ on a single physical line using ";"
:_ a=1; b=2; c=3; d=4
14. BASIC · 1964
10 FOR X=99 TO 1 STEP -1
20 PRINT X;"bottle";
30 IF X<>1 THEN PRINT "s";
40 PRINT " of beer on the wall,";X;"bottle";
50 IF X<>1 THEN PRINT "s";
60 PRINT " of beer"
70 PRINT "Take one down and pass it around,"
80 PRINT X-1;"bottle";
90 IF X<>1 THEN PRINT "s";
100 PRINT " of beer on the wall"
110 NEXT
15.
16. SCHEME · 1970
(define bottles
(lambda (n)
(cond ((= n 0) (display "No more bottles"))
((= n 1) (display "One bottle"))
(else (display n) (display " bottles")))
(display " of beer")))
(define beer
(lambda (n)
(if (> n 0)
(begin
(bottles n) (display " on the wall") (newline)
(bottles n) (newline)
(display "Take one down, pass it around") (newline)
(bottles (- n 1)) (display " on the wall") (newline)
(newline)
(beer (- n 1))))))
(beer 99)
17. PYTHON · 1991
for quant in range(99, 0, -1):
if quant > 1:
print quant, "bottles of beer on the wall,", quant, "bottles of beer."
if quant > 2:
suffix = str(quant - 1) + " bottles of beer on the wall."
else:
suffix = "1 bottle of beer on the wall."
elif quant == 1:
print "1 bottle of beer on the wall, 1 bottle of beer."
suffix = "no more beer on the wall!"
print "Take one down, pass it around,", suffix
print "--"
18. LUA · 1993
function PrintBottleNumber(n)
local bs
if n == 0 then
bs = "No more bottles"
elseif n == 1 then
bs = "One bottle"
else
bs = n .. " bottles"
end
return bs .. " of beer"
end
for bn = 99, 1, -1 do
write(PrintBottleNumber(bn), " on the wall, n")
write(PrintBottleNumber(bn), "n")
write("Take one down and pass it around,n")
write(PrintBottleNumber(bn-1), " on the wall, nn")
end
write("No more bottles of beer on the wall,nNo more bottles of beern")
write("Go to the store, buy some more!n")
19. RUBY · 1995
puts; puts " It's beer song time!"; puts
def bottles(n)
n == 1 ? "#{n} bottle" : "#{n} bottles"
end
@count = 99
@count.downto(1) {
puts <<BEERSONG
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#{bottles(@count)} of beer on the wall
#{bottles(@count)} of beer
Take one down, pass it around
#{bottles(@count -= 1)} of beer on the wall
BEERSONG
}
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
puts; puts " No more beer on the wall"
20. PHP · 1995
<?
for ($i=99; $i>=0; $i--)
{
if ($i==0) printf ("No more bottles of beer on the wall, no more bottles of
beer.<br>
Go to the store and buy some more, 99 bottles of beer on the wall.<br><br>";
elseif ($i==1) printf ("1 bottle of beer on the wall, 1 bottle of beer.<br>
Take one down and pass it around, no more bottles of beer on the wall.<br><br>";
else printf ($i." bottles of beer on the wall, ".$i." bottles of beer.<br>
Take one down and pass it around, ".($i-1)." bottles of beer on the
wall.<br><br>";
}
?>
21. INTERCAL · 1972
DO ,1 <- #13
PLEASE DO ,1 SUB #1 <- #238
DO ,1 SUB #2 <- #108
DO ,1 SUB #3 <- #112
DO ,1 SUB #4 <- #0
DO ,1 SUB #5 <- #64
DO ,1 SUB #6 <- #194
DO ,1 SUB #7 <- #48
PLEASE DO ,1 SUB #8 <- #22
DO ,1 SUB #9 <- #248
DO ,1 SUB #10 <- #168
DO ,1 SUB #11 <- #24
DO ,1 SUB #12 <- #16
DO ,1 SUB #13 <- #162
PLEASE READ OUT ,1
PLEASE GIVE UP
24. BEFUNGE · 1993
v v01:1:{CODE}{CODE}!:p15-<
0 {befunge} >" ekaT">v
0>>.0"llaw eht no "v<#,:
", >"eno"^>0 #"^1^_v
c1,>51g#^_"ti"^. >vr : $
"::^" down, pass "<e 5
>^|*25,<^ # i e ^g1<
,>052*":dnuor t"vbv:<
v0_^ . , ^< " "
>52*".ll"v >,^ fb e
v<v<v_$!|>"aw eht no r"v
""" ,: >" ;"^ f ^<@
meo >^"bottle"< "o $
o m^"re:"<v _^#g15< v_^
s"" >52*^>"s"^v"les"<,:
"^< ^"99 bott"< >^>^<
>" yub ,erots eht ot oG"^
25. BEFUNGE · 1993
> v
v ,,,,,"Hello"<
>48*, v
v,,,,,,"World!"<
>25*,@
26. CHEF · 2002
Hello World Souffle.
This recipe prints the immortal words "Hello world!", in a basically brute force way. It also
makes a lot of food for one person.
Ingredients.
72 g haricot beans
101 eggs
108 g lard
111 cups oil
32 zucchinis
119 ml water
114 g red salmon
100 g dijon mustard
33 potatoes
Method.
Put potatoes into the mixing bowl. Put dijon mustard into the mixing bowl. Put lard into the
mixing bowl. Put red salmon into the mixing bowl. Put oil into the mixing bowl. Put water into
the mixing bowl. Put zucchinis into the mixing bowl. Put oil into the mixing bowl. Put lard
into the mixing bowl. Put lard into the mixing bowl. Put eggs into the mixing bowl. Put haricot
beans into the mixing bowl. Liquefy contents of the mixing bowl. Pour contents of the mixing
bowl into the baking dish.
Serves 1.
28. SHAKESPEARE
Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.
Act I: Hamlet's insults and flattery.
Scene I: The insulting of Romeo.
[Enter Hamlet and Romeo]
Hamlet:
You lying stupid fatherless big smelly half-witted coward! You are as
stupid as the difference between a handsome rich brave hero and thyself!
Speak your mind!
You are as brave as the sum of your fat little stuffed misused dusty
old rotten codpiece and a beautiful fair warm peaceful sunny summer's
day. You are as healthy as the difference between the sum of the
sweetest reddest rose and my father and yourself! Speak your mind!
You are as cowardly as the sum of yourself and the difference
between a big mighty proud kingdom and a horse. Speak your mind.
Speak your mind!
[Exit Romeo]
Scene II: The praising of Juliet.
[Enter Juliet]
Hamlet:
Thou art as sweet as the sum of the sum of Romeo and his horse and his
black cat! Speak thy mind!
[Exit Juliet]
31. INFORM 7 · 2006
"Hello World" by "I.F. Author"
The world is a room.
When play begins, say "Hello, world."
32. ELIXIR · 2011defmodule BeerSong do
@moduledoc """
This showcases recursion, pattern-matching, multi-line strings,
default arguments, embedded docs and pipes.
"""
import String, only: [downcase: 1]
@drink "Take one down and pass it around"
@no_beer "Go to the store and buy some more"
def sing(beers) when beers < 0, do: :the_end
def sing(beers 99) do
beers
|> song
|> lyrics
|> IO.puts
sing(beers - 1)
end
defp lyrics({count, next_count, phrase}) do
"""
#{count} of beer on the wall, #{downcase(count)} of beer.
#{phrase}, #{next_count} of beer on the wall.
"""
end
defp song(0), do: {"No more bottles", "99 bottles", @no_beer}
defp song(1), do: {"1 bottle", "no more bottles", @drink}
defp song(2), do: {"2 bottles", "1 bottle", @drink}
defp song(beers), do: {"#{beers} bottles", "#{beers - 1} bottles", @drink}
end