package main

import (
    "fmt"
    "strings"
)

// a number of strings
var n = []string{
    "---------- Ice and Fire ------------",
    "                                    ",
    "fire, in end will world the say Some",
    "ice. in say Some                    ",
    "desire of tasted I've what From     ",
    "fire. favor who those with hold I   ",
    "                                    ",
    "... elided paragraph last ...       ",
    "                                    ",
    "Frost Robert -----------------------",
}

func main() {
    for i, s := range n {
        t := strings.Fields(s) // tokenize
        // reverse
        last := len(t) - 1
        for j, k := range t[:len(t)/2] {
            t[j], t[last-j] = t[last-j], k
        }
        n[i] = strings.Join(t, " ")
    }
    // display result
    for _, t := range n {
        fmt.Println(t)
    }
}


def text = new StringBuilder()
    .append('---------- Ice and Fire ------------\n')
    .append('                                    \n')
    .append('fire, in end will world the say Some\n')
    .append('ice. in say Some                    \n')
    .append('desire of tasted I\'ve what From     \n')
    .append('fire. favor who those with hold I   \n')
    .append('                                    \n')
    .append('... elided paragraph last ...       \n')
    .append('                                    \n')
    .append('Frost Robert -----------------------\n').toString()

text.eachLine { line ->
    println "$line   -->   ${line.split(' ').reverse().join(' ')}"
}


revstr :: String -> String
revstr = unwords . reverse . words -- point-free style
--equivalent:
--revstr s = unwords (reverse (words s))

revtext :: String -> String
revtext = unlines . map revstr . lines -- applies revstr to each line independently

test = revtext "---------- Ice and Fire ------------\n\
        \\n\
        \fire, in end will world the say Some\n\
        \ice. in say Some\n\
        \desire of tasted I've what From\n\
        \fire. favor who those with hold I\n\
        \\n\
        \... elided paragraph last ...\n\
        \\n\
        \Frost Robert -----------------------\n" --multiline string notation requires \ at end and start of lines, and \n to be manually input


procedure main()
    every write(rWords(&input))
end

procedure rWords(f)
    every !f ? {
        every (s := "") := genWords() || s
        suspend s
        }
end

procedure genWords()
    while w := 1(tab(upto(" \t")),tab(many(" \t"))) || " " do suspend w
end


   ([:;@|.[:<;.1 ' ',]);._2]0 :0
---------- Ice and Fire ------------

  fire, in end will world the say Some
  ice. in say Some
  desire of tasted I've what From
  fire. favor who those with hold I

   ... elided paragraph last ...

  Frost Robert -----------------------
)
 ------------ Fire and Ice ----------

 Some say the world will end in fire,
 Some say in ice.
 From what I've tasted of desire
 I hold with those who favor fire.

 ... last paragraph elided ...

 ----------------------- Robert Frost


public class ReverseWords {

    static final String[] lines = {
        " ----------- Ice and Fire ----------- ",
        "                                      ",
        " fire, in end will world the say Some ",
        " ice. in say Some                     ",
        " desire of tasted I've what From      ",
        " fire. favor who those with hold I    ",
        "                                      ",
        " ... elided paragraph last ...        ",
        " Frost Robert ----------------------- "};

    public static void main(String[] args) {
        for (String line : lines) {
            String[] words = line.split("\\s");
            for (int i = words.length - 1; i >= 0; i--)
                System.out.printf("%s ", words[i]);
            System.out.println();
        }
    }
}


var strReversed =
"---------- Ice and Fire ------------\n\
\n\
fire, in end will world the say Some\n\
ice. in say Some\n\
desire of tasted I've what From\n\
fire. favor who those with hold I\n\
\n\
... elided paragraph last ...\n\
\n\
Frost Robert -----------------------";

function reverseString(s) {
  return s.split('\n').map(
    function (line) {
      return line.split(/\s/).reverse().join(' ');
    }
  ).join('\n');
}

console.log(
  reverseString(strReversed)
);


split("[ \t\n\r]+") | reverse | join(" ")


var strReversed =
"---------- Ice and Fire ------------\n
fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I
\n... elided paragraph last ...\n
Frost Robert -----------------------";

function reverseString(s) {
    return s.split('\n').map(
      function (line) {
          return line.split().reverse().join(' ');
      }
    ).join('\n');
}

;reverseString('Hey you, Bub!');
;strReversed;
;reverseString(strReversed);

/*
=!EXPECTSTART!=
reverseString('Hey you, Bub!') ==> Bub! you, Hey
strReversed ==> ---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------
reverseString(strReversed) ==> ------------ Fire and Ice ----------

Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favor fire.

... last paragraph elided ...

----------------------- Robert Frost
=!EXPECTEND!=
*/


revstring (str) = join(reverse(split(str, " ")), " ")


fun reversedWords(s: String) = s.split(" ").filter { it.isNotEmpty() }.reversed().joinToString(" ")

fun main() {
    val s = "Hey you, Bub!"
    println(reversedWords(s))
    println()
    val sl = listOf(
        " ---------- Ice and Fire ------------ ",
        "                                      ",
        " fire, in end will world the say Some ",
        " ice. in say Some                     ",
        " desire of tasted I've what From      ",
        " fire. favor who those with hold I    ",
        "                                      ",
        " ... elided paragraph last ...        ",
        "                                      ",
        " Frost Robert ----------------------- ",
    )
    sl.forEach { println(reversedWords(it)) }
}


#!/bin/ksh

# Reverse words in a string

#	# Variables:
#
typeset -a wArr
integer i

 ######
# main #
 ######

while read -A wArr; do
	for ((i=${#wArr[@]}-1; i>=0; i--)); do
		printf "%s " "${wArr[i]}"
	done
	echo
done << EOF
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...
Frost Robert -----------------------
EOF


1) We write a function

{def line_reverse
 {def line_reverse.r
  {lambda {:i :txt :length}
   {if {> :i :length}
    then
    else {br}{A2S {A.reverse! {A.get :i :txt}}}
         {line_reverse.r {+ :i 1} :txt :length}}}}
 {lambda {:txt}
  {let { {:a {line_split {:txt}}} }
  {line_reverse.r 0 :a {- {A.length :a} 1}}}} }
-> line_reverse

where A2S translates an array into a sentence

{def A2S
 {lambda {:a}
  {if {A.empty? :a}
   then
   else {A.first :a} {A2S {A.rest :a}}}}}
-> A2S

and line_split is a javascript primitive directly written in the wiki page,
added to the dictionary and returning an array of lines

LAMBDATALK.DICT['line_split'] = function () {
  var args = arguments[0].split("\n");
  var str = "{A.new ";
  for (var i=0; i< args.length; i++)
    str += "{A.new " + args[i] + "} ";
  str += "}";
  return LAMBDATALK.eval_forms( str )
};

2) input (from a simple text source without any presetting)

{def rosetta
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I''ve what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------
}
-> rosetta

3) calling the function:

{line_reverse rosetta}
->

3) output

------------ Fire and Ice ----------

Some say the world will end in fire,
Some say in ice.
From what I''ve tasted of desire
I hold with those who favor fire.

... last paragraph elided ...

----------------------- Robert Frost


for i = 1 to 10
    read string$
    print reverse$(string$)
next
end

function reverse$(string$)
    token$="*"
    while token$<>""
        i=i+1
        token$ = word$(string$, i)
        output$=token$+" "+output$
    wend
    reverse$ = trim$(output$)
end function

data "---------- Ice and Fire ------------"
data ""
data "fire, in end will world the say Some"
data "ice. in say Some"
data "desire of tasted I've what From"
data "fire. favor who those with hold I"
data ""
data "... elided paragraph last ..."
data ""
data "Frost Robert -----------------------"


repeat for each line txtln in fld "Fieldtxt"
    repeat with i = the number of words of txtln down to 1
        put word i of txtln & space after txtrev
    end repeat
    put cr after txtrev  -- preserve line
end repeat
put txtrev


poem =
    """
    ---------- Ice and Fire ------------

    fire, in end will world the say Some
    ice. in say Some
    desire of tasted I've what From
    fire. favor who those with hold I

    ... elided paragraph last ...

    Frost Robert -----------------------
    """

reverse-words  = (.split ' ') >> (.reverse!) >> (.join ' ')
reverse-string = (.split '\n') >> (.map reverse-words) >> (.join '\n')
reverse-string poem


do.until [
  make "line readlist
  print reverse :line
] [word? :line]
bye


local lines = {}
for line in (s .. "\n"):gmatch("(.-)\n") do
	local this = {}
	for word in line:gmatch("%S+") do
		table.insert(this, 1, word)
	end
	lines[#lines + 1] = table.concat(this, " ")
end
print(table.concat(lines, "\n"))


while (true) do
	input := readline("input.txt"):
	if input = 0 then break: fi:
	input := StringTools:-Trim(input): # remove leading/trailing space
	input := StringTools:-Join(ListTools:-Reverse(StringTools:-Split(input, " "))," "):
	printf("%s\n", input):
od:


poem = "---------- Ice and Fire ------------

     fire, in end will world the say Some
     ice. in say Some
     desire of tasted I've what From
     fire. favor who those with hold I

     ... elided paragraph last ...

     Frost Robert -----------------------";
lines = StringSplit[poem, "\n"];
wordArray = StringSplit[#] &   @ lines ;
reversedWordArray = Reverse[#] & /@ wordArray ;
linesWithReversedWords =
  StringJoin[Riffle[#, " "]] & /@ reversedWordArray;
finaloutput = StringJoin[Riffle[#, "\n"]] &  @ linesWithReversedWords


function testReverseWords
    testStr = {'---------- Ice and Fire ------------' ; ...
        ''                                            ; ...
        'fire, in end will world the say Some'        ; ...
        'ice. in say Some'                            ; ...
        'desire of tasted I''ve what From'            ; ...
        'fire. favor who those with hold I'           ; ...
        ''                                            ; ...
        '... elided paragraph last ...'               ; ...
        ''                                            ; ...
        'Frost Robert -----------------------'        };
    for k = 1:length(testStr)
        fprintf('%s\n', reverseWords(testStr{k}))
    end
end

function strOut = reverseWords(strIn)
    strOut = strtrim(strIn);
    if ~isempty(strOut)
        % Could use strsplit() instead of textscan() in R2013a or later
        words = textscan(strOut, '%s');
        words = words{1};
        strOut = strtrim(sprintf('%s ', words{end:-1:1}));
    end
end


-- MAXScript : Reverse words in a string : N.H. 2019
--
(
text = stringstream "---------- Ice and Fire ------------\n\nfire, in end will world the say Some\nice. in say Some\ndesire of tasted I've what From\nfire. favor who those with hold I\n\n... elided paragraph last ...\n\nFrost Robert -----------------------\n"
clearListener()
seek text 0
while eof text == false do
(
nextLine = (readLine text)
if nextLine == "" then
(
print ""
continue
) -- end of if
revLine = ""
eachWord = filterString nextLine " "
for k = eachWord.count to 1 by -1 do
(
revLine = revLine + eachWord[k]
-- Only add space between words not at the end of line
if k != 1 then revLine = revLine + " "
) -- end of for k
print revLine
) -- end of while eof
)


lines = ["==========================================",
    "|  ---------- Ice and Fire ------------  |",
    "|                                        |",
    "|  fire, in end will world the say Some  |",
    "|  ice. in say Some                      |",
    "|  desire of tasted I've what From       |",
    "|  fire. favor who those with hold I     |",
    "|                                        |",
    "|  ... elided paragraph last ...         |",
    "|                                        |",
    "|  Frost Robert -----------------------  |",
    "=========================================="]

for line in lines
    oldLine = line.split
    newLine = []
    while oldLine
// the line below line retains the outer box format
        newLine.push oldLine.pop
// alternate format, replace above line with below two lines below to strip all superfluous spaces
//	word = oldLine.pop
//	if word != "" then newLine.push word
    end while
    print newLine.join
end for


MODULE ReverseWords;

FROM STextIO IMPORT
  WriteString, WriteLn;
FROM Strings IMPORT
  Assign, Concat, Append;

CONST
  NL = CHR(10);
  Sp = ' ';
  Txt = "---------- Ice and Fire -----------" + NL +
    NL +
    "fire, in end will world the say Some" + NL +
    "ice. in say Some" + NL +
    "desire of tasted I've what From" + NL +
    "fire. favor who those with hold I" + NL +
    NL +
    "... elided paragraph last ..." + NL +
    NL +
    "Frost Robert -----------------------" + NL;

TYPE
  String400 = ARRAY [0 .. 399] OF CHAR;

PROCEDURE AddWord(Source: ARRAY OF CHAR; VAR INOUT Destination: ARRAY OF CHAR);
VAR
  R: String400;
BEGIN
  Concat(Source, Sp, R);
  Append(Destination, R);
  Assign(R, Destination);
END AddWord;

VAR
  I: CARDINAL;
  SingleWord, CurrentLine: String400;
  C: CHAR;

BEGIN
  SingleWord := "";
  CurrentLine := "";
  FOR I := 0 TO HIGH(Txt) DO
    C := Txt[I];
    CASE C OF
      Sp:
        AddWord(SingleWord, CurrentLine);
        SingleWord := ""; |
      NL:
        AddWord(SingleWord, CurrentLine);
        WriteString(CurrentLine);
        WriteLn;
        SingleWord := "";
        CurrentLine := ""; |
    ELSE
      Append(C, SingleWord);
    END;
  END;
END ReverseWords.


def reverse_words(string)
        tokens = split(string, " ")
        if len(tokens) = 0
                return ""
        end

        ret_str = ""
        for i in range(len(tokens) - 1, 0)
                ret_str += tokens[i] + " "
        end
        return ret_str.substring(0, len(ret_str) - 1)
end

data = "---------- Ice and Fire ------------\n" +\
       "                                    \n" +\
       "fire, in end will world the say Some\n" +\
       "ice. in say Some                    \n" +\
       "desire of tasted I've what From     \n" +\
       "fire. favor who those with hold I   \n" +\
       "                                    \n" +\
       "... elided paragraph last ...       \n" +\
       "Frost Robert -----------------------\n"

for line in split(data, "\n")
        println reverse_words(line)
end


# Define a function to convert a list of strings to a single string.
join is rest link (' ' eachboth link)

iterate (write join reverse (' ' string_split)) \
  \
  \
  '------------ Eldorado ----------' \
  '' \
  '... here omitted lines ...' \
  '' \
  'Mountains the "Over' \
  'Moon, the Of' \
  'Shadow, the of Valley the Down' \
  'ride," boldly Ride,' \
  'replied,--- shade The' \
  'Eldorado!" for seek you "If' \
  '' \
  'Poe Edgar -----------------------'


import strutils

let text = """---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------"""

proc reversed*[T](a: openArray[T], first, last: int): seq[T] =
  result = newSeq[T](last - first + 1)
  var x = first
  var y = last
  while x <= last:
    result[x] = a[y]
    dec(y)
    inc(x)

proc reversed*[T](a: openArray[T]): seq[T] =
  reversed(a, 0, a.high)

for line in text.splitLines():
  echo line.split(' ').reversed().join(" ")


use Collection;

class Reverselines {
  function : Main(args : String[]) ~ Nil {
    lines := List->New();
    lines->AddBack("---------- Ice and Fire ------------");
    lines->AddBack("");
    lines->AddBack("fire, in end will world the say Some");
    lines->AddBack("ice. in say Some");
    lines->AddBack("desire of tasted I've what From");
    lines->AddBack("fire. favor who those with hold I");
    lines->AddBack("");
    lines->AddBack("... elided paragraph last ...");
    lines->AddBack("");
    lines->AddBack("Frost Robert -----------------------");

    lines->Rewind();
    each(i : lines) {
      words := lines->Get()->As(String)->Split(" ");
      if(words <> Nil) {
        for(j := words->Size() - 1; j > -1; j-=1;) {
          IO.Console->Print(words[j])->Print(" ");
        };
      };
      IO.Console->PrintLine();
      lines->Next();
    };
  }
}


#load "str.cma"
let input = ["---------- Ice and Fire ------------";
        "";
        "fire, in end will world the say Some";
        "ice. in say Some";
        "desire of tasted I've what From";
        "fire. favor who those with hold I";
        "";
        "... elided paragraph last ...";
        "";
        "Frost Robert -----------------------"];;

let splitted = List.map (Str.split (Str.regexp " ")) input in
let reversed = List.map List.rev splitted in
let final = List.map (String.concat " ") reversed in
List.iter print_endline final;;


: revWords(s)
   s words reverse unwords ;

: reverseWords
   "---------- Ice and Fire ------------" revWords println
   "                                    " revWords println
   "fire, in end will world the say Some" revWords println
   "ice. in say Some                    " revWords println
   "desire of tasted I've what From     " revWords println
   "fire. favor who those with hold I   " revWords println
   "                                    " revWords println
   "... elided paragraph last ...       " revWords println
   "                                    " revWords println
   "Frost Robert -----------------------" revWords println ;


program Reverse_words(Output);
{$H+}

const
  nl = chr(10); // Linefeed
  sp = chr(32); // Space
  TXT =
  '---------- Ice and Fire -----------'+nl+
  nl+
  'fire, in end will world the say Some'+nl+
  'ice. in say Some'+nl+
  'desire of tasted I''ve what From'+nl+
  'fire. favor who those with hold I'+nl+
  nl+
  '... elided paragraph last ...'+nl+
  nl+
  'Frost Robert -----------------------'+nl;

var
  I : integer;
  ew, lw : ansistring;
  c : char;

function addW : ansistring;
var r : ansistring = '';
begin
  r := ew + sp + lw;
  ew := '';
  addW := r
end;

begin
  ew := '';
  lw := '';

  for I := 1 to strlen(TXT) do
  begin
    c := TXT[I];
    case c of
      sp : lw := addW;
      nl : begin writeln(addW); lw := '' end;
      else ew := ew + c
    end;
  end;
  readln;
end.


print join(" ", reverse split), "\n" for <DATA>;
__DATA__
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------


with javascript_semantics
constant test="""
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------
"""
sequence lines = split(test,'\n')
for i=1 to length(lines) do
    lines[i] = join(reverse(split(lines[i])))
end for
puts(1,join(lines,"\n"))


include ..\Utilitys.pmt

"---------- Ice and Fire ------------"
""
"fire, in end will world the say Some"
"ice. in say Some"
"desire of tasted I've what From"
"fire. favor who those with hold I"
""
"... elided paragraph last ..."
""
"Frost Robert -----------------------"

stklen tolist
len for var i
    i get split reverse i set
endfor
len for
    get len dup if
        for get print " " print endfor
    else drop endif
    drop nl
endfor


<?php

 function strInv ($string) {

 	$str_inv = '' ;

	 for ($i=0,$s=count($string);$i<$s;$i++){
	 	$str_inv .= implode(' ',array_reverse(explode(' ',$string[$i])));
	 	$str_inv .= '<br>';
	 }

 	return $str_inv;

 }

 $string[] =  "---------- Ice and Fire ------------";
 $string[] =  "";
 $string[] =  "fire, in end will world the say Some";
 $string[] =  "ice. in say Some";
 $string[] =  "desire of tasted I've what From";
 $string[] =  "fire. favor who those with hold I";
 $string[] =  "";
 $string[] =  "... elided paragraph last ...";
 $string[] =  "";
 $string[] =  "Frost Robert ----------------------- ";

echo strInv($string);


(in "FireIce.txt"
 (until (eof)
  (prinl (glue " " (flip (split (line) " "))))))


string story = #"---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------";

foreach(story/"\n", string line)
    write("%s\n", reverse(line/" ")*" ");


rev: procedure options (main);          /* 5 May 2014 */
   declare (s, reverse) character (50) varying;
   declare (i, j) fixed binary;
   declare in file;

   open file (in) title ('/REV-WRD.DAT,type(text),recsize(5> Nil) {
        for(j := words->Size() - 1; j > -1; j-=1;) {
          IO.Console->Print(words[j])->Print(" ");
        };
      };
      IO.Console->PrintLine();
      lines->Next();
    };
  }
}0)');

   do j = 1 to 10;
      get file (in) edit (s) (L);
      put skip list (trim(s));

      reverse = '';

      do while (length(s) > 0);
         s = trim(s);
         i = index(s, ' ');
         if i = 0 then
            if s ^= '' then i = length(s)+1;
         if i > 0 then reverse = substr(s, 1, i-1) || ' ' || reverse;
         if length(s) = i then s = ''; else s = substr(s, i);
      end;
      put edit ('---> ', reverse) (col(40), 2 A);
   end;
end rev;


Function Reverse-Words($lines) {
    $lines | foreach {
        $array = $PSItem.Split(' ')
        $array[($array.Count-1)..0] -join ' '
    }
}

$lines =
"---------- Ice and Fire ------------",
"",
"fire, in end will world the say Some",
"ice. in say Some",
"desire of tasted I've what From",
"fire. favor who those with hold I",
"",
"... elided paragraph last ...",
"",
"Frost Robert -----------------------"

Reverse-Words($lines)


		org	100h
		jmp	test
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;; Takes a 16-bit integer in HL, and stores it
		;; as a 0-terminated string starting at BC.
		;; On exit, all registers destroyed; BC pointing at
		;; end of string.
mkroman:	push	h	; put input on stack
		lxi	h,mkromantab
mkromandgt:	mov	a,m	; scan ahead to next entry
		ana	a
		inx	h
		jnz	mkromandgt
		xthl		; load number
		mov	a,h	; if zero, we're done
		ora	l
		jz	mkromandone
		xthl		; load next entry from table
		mov	e,m	; de = number
		inx	h
		mov	d,m
		inx	h
		xthl		; load number
		xra	a	; find how many we need
subtract:	inr	a	; with trial subtraction
		dad	d
		jc	subtract
		push	psw	; keep counter
		mov	a,d	; we subtracted one too many
		cma		; so we need to add one back
		mov	d,a
		mov	a,e
		cma
		mov	e,a
		inx	d
		dad	d
		pop	d	; restore counter (into D)
		xthl		; load table pointer
stringouter:	dcr	d	; do we need to include one?
		jz	mkromandgt
		push	h	; keep string location
stringinner:	mov	a,m	; copy string into target
		stax	b
		ana	a	; done yet?
		jz	stringdone
		inx	h
		inx	b	; copy next character
		jmp	stringinner
stringdone:	pop	h	; restore string location
		jmp	stringouter
mkromandone:	pop	d	; remove temporary variable from stack
		ret
mkromantab:	db	0
		db	18h,0fch,'M',0		; The value for each entry
		db	7ch,0fch,'CM',0		; is stored already negated
		db	0ch,0feh,'D',0		; so that it can be immediately
		db	70h,0feh,'CD',0		; added using `dad'.
		db	9ch,0ffh,'C',0		; This also has the convenient
		db	0a6h,0ffh,'XC',0	; property of not having any
		db	0ceh,0ffh,'L',0		; zero bytes except the string
		db	0d8h,0ffh,'XL',0	; and row terminators.
		db	0f6h,0ffh,'X',0
		db	0f7h,0ffh,'IX',0
		db	0fbh,0ffh,'V',0
		db	0fch,0ffh,'IV',0
		db	0ffh,0ffh,'I',0
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;; Test code
test:		mvi	c,10	; read string from console
		lxi	d,dgtbufdef
		call	5
		lxi	h,0	; convert to integer
		lxi	b,dgtbuf
readdgt:	ldax	b
		ana	a
		jz	convert
		dad	h	; hl *= 10
		mov	d,h
		mov	e,l
		dad	h
		dad	h
		dad	d
		sui	'0'
		mov	e,a
		mvi	d,0
		dad	d
		inx	b
		jmp	readdgt
convert:	lxi	b,romanbuf	; convert to roman
		call	mkroman
		mvi	a,'$'	; switch string terminator
		stax	b
		mvi	c,9	; output result
		lxi	d,romanbuf
		jmp	5
nl:		db	13,10,'$'
dgtbufdef:	db	5,0
dgtbuf:		ds	6
romanbuf:


	mov ax,0070h
	call EncodeRoman
	mov si,offset StringRam
	call PrintString
	call NewLine

	mov ax,1776h
	call EncodeRoman
	mov si,offset StringRam
	call PrintString
	call NewLine

	mov ax,2021h
	call EncodeRoman
	mov si,offset StringRam
	call PrintString
	call NewLine

	mov ax,3999h
	call EncodeRoman
	mov si,offset StringRam
	call PrintString
	call NewLine

	mov ax,4000h
	call EncodeRoman
	mov si,offset StringRam

	ReturnToDos     ;macro that calls the int that exits dos


a$ =    "---------- Ice and Fire ------------" +#CRLF$+
        "                                    " +#CRLF$+
        "fire, in end will world the say Some" +#CRLF$+
        "ice. in say Some                    " +#CRLF$+
        "desire of tasted I've what From     " +#CRLF$+
        "fire. favor who those with hold I   " +#CRLF$+
        "                                    " +#CRLF$+
        "... elided paragraph last ...       " +#CRLF$+
        "                                    " +#CRLF$+
        "Frost Robert -----------------------" +#CRLF$
a$ =    "Hey you, Bub!                       " +#CRLF$+#CRLF$+ a$

OpenConsole()
For p1=1 To CountString(a$,#CRLF$)
  b$=StringField(a$,p1,#CRLF$) : c$=""
  For p2=1 To CountString(b$,Chr(32))+1
    c$=StringField(b$,p2,Chr(32))+Space(1)+c$
  Next
  PrintN(LSet(b$,36,Chr(32))+" ---> "+Trim(c$))
Next
Input()


 text = '''\
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------'''

for line in text.split('\n'): print(' '.join(line.split()[::-1]))


DEFINE PTR="CARD"
CARD ARRAY arabic=[1000 900 500 400 100 90 50 40 10 9 5 4 1]
PTR ARRAY roman(13)

PROC InitRoman()
  roman(0)="M" roman(1)="CM" roman(2)="D" roman(3)="CD"
  roman(4)="C" roman(5)="XC" roman(6)="L" roman(7)="XL"
  roman(8)="X" roman(9)="IX" roman(10)="V" roman(11)="IV" roman(12)="I"
RETURN

PROC EncodeRomanNumber(CARD n CHAR ARRAY res)
  BYTE i,len
  CHAR ARRAY tmp

  res(0)=0 len=0
  FOR i=0 TO 12
  DO
    WHILE arabic(i)<=n
    DO
      tmp=roman(i)
      SAssign(res,tmp,len+1,len+1+tmp(0))
      len==+tmp(0)
      n==-arabic(i)
    OD
  OD
  res(0)=len
RETURN

PROC Main()
  CARD ARRAY data=[1990 2008 5555 1666 3888 3999]
  BYTE i
  CHAR ARRAY r(20)

  InitRoman()
  FOR i=0 TO 5
  DO
    EncodeRomanNumber(data(i),r)
    PrintF("%U=%S%E",data(i),r)
  OD
RETURN


function arabic2roman(num:Number):String {
	var lookup:Object = {M:1000, CM:900, D:500, CD:400, C:100, XC:90, L:50, XL:40, X:10, IX:9, V:5, IV:4, I:1};
	var roman:String = "", i:String;
	for (i in lookup) {
		while (num >= lookup[i]) {
			roman += i;
			num -= lookup[i];
		}
	}
	return roman;
}
trace("1990 in roman is " + arabic2roman(1990));
trace("2008 in roman is " + arabic2roman(2008));
trace("1666 in roman is " + arabic2roman(1666));


  ' [ $ "  ---------- Ice and Fire ------------  "
      $ ""
      $ "   fire, in end will world the say Some "
      $ "   ice. in say Some                     "
      $ "   desire of tasted I've what From      "
      $ "   fire. favor who those with hold I    "
      $ ""
      $ "   ... elided paragraph last ...        "
      $ ""
      $ "   Frost Robert ----------------------- " ]

  witheach
    [ do nest$ reverse
         witheach
           [ echo$ sp ]
      cr ]


whack <- function(s) {
  paste( rev( unlist(strsplit(s, " "))), collapse=' ' ) }

poem <- unlist( strsplit(
'------------ Eldorado ----------

... here omitted lines ...

Mountains the "Over
Moon, the Of
Shadow, the of Valley the Down
ride," boldly Ride,
replied,--- shade The
Eldorado!" for seek you "If

Poe Edgar -----------------------', "\n"))

for (line in poem) cat( whack(line), "\n" )


#lang racket/base

(require racket/string)

(define (split-reverse str)
  (string-join
   (reverse
    (string-split str))))

(define poem
  "---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------")

(let ([poem-port (open-input-string poem)])
  (let loop ([l (read-line poem-port)])
    (unless (eof-object? l)
      (begin (displayln (split-reverse l))
              (loop (read-line poem-port))))))


with Ada.Text_IO;  use Ada.Text_IO;

procedure Roman_Numeral_Test is
   function To_Roman (Number : Positive) return String is
      subtype Digit is Integer range 0..9;
      function Roman (Figure : Digit; I, V, X : Character) return String is
      begin
         case Figure is
            when 0 => return "";
            when 1 => return "" & I;
            when 2 => return I & I;
            when 3 => return I & I & I;
            when 4 => return I & V;
            when 5 => return "" & V;
            when 6 => return V & I;
            when 7 => return V & I & I;
            when 8 => return V & I & I & I;
            when 9 => return I & X;
         end case;
      end Roman;
   begin
      pragma Assert (Number >= 1 and Number < 4000);
      return
         Roman (Number / 1000,       'M', ' ', ' ') &
         Roman (Number / 100 mod 10, 'C', 'D', 'M') &
         Roman (Number / 10 mod 10,  'X', 'L', 'C') &
         Roman (Number mod 10,       'I', 'V', 'X');
   end To_Roman;
begin
   Put_Line (To_Roman (1999));
   Put_Line (To_Roman (25));
   Put_Line (To_Roman (944));
end Roman_Numeral_Test;


Red []
foreach line
split
{---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------} newline [
 print reverse split line " "
]


/*REXX program reverses the order of tokens in a string (but not the letters).*/
@.=;                    @.1  =  "---------- Ice and Fire ------------"
                        @.2  =  ' '
                        @.3  =  "fire, in end will world the say Some"
                        @.4  =  "ice. in say Some"
                        @.5  =  "desire of tasted I've what From"
                        @.6  =  "fire. favor who those with hold I"
                        @.7  =  ' '
                        @.8  =  "... elided paragraph last ..."
                        @.9  =  ' '
                        @.10 =  "Frost Robert -----------------------"

  do j=1  while  @.j\==''              /*process each of the 10 lines of poem.*/
  $=                                   /*nullify the  $  string (the new line)*/
     do k=1  for  words(@.j)           /*process each word in a   @.j  string.*/
     $=word(@.j,k) $                   /*prepend a word to the new line  ($). */
     end   /*k*/                       /* [↑]  we could do this another way.  */

  say $                                /*display the newly constructed line.  */
  end      /*j*/                       /*stick a fork in it,  we're all done. */


aList = str2list("
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------
")
aList = str2list(cStr)
for x in aList
   x2 = substr(x," ",nl) alist2 = str2list(x2) aList2 = reverse(aList2)
   for y in aList2 see y + " " next see nl
next


puts <<EOS
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------
EOS
  .each_line.map {|line| line.split.reverse.join(' ')}


for i = 1 to 10
    read string$
   j = 1
   r$ = ""
    while word$(string$,j) <> ""
     r$ = word$(string$,j) + " " + r$
     j = j + 1
    WEND
    print r$
next
end

data "---------- Ice and Fire ------------"
data ""
data "fire, in end will world the say Some"
data "ice. in say Some"
data "desire of tasted I've what From"
data "fire. favor who those with hold I"
data ""
data "... elided paragraph last ..."
data ""
data "Frost Robert -----------------------"


const TEXT: &'static str =
"---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------";

fn main() {
    println!("{}",
             TEXT.lines() // Returns iterator over lines
             .map(|line|  // Applies closure to each item in iterator (for each line)
                  line.split_whitespace() // Returns iterator of words
                  .rev() // Reverses iterator of words
                  .collect::<Vec<_>>() // Collects words into Vec<&str>
                  .join(" ")) // Convert vector of words back into line
             .collect::<Vec<_>>() // Collect lines into Vec<String>
             .join("\n")); // Concatenate lines into String
}


variable ln, in =
  ["---------- Ice and Fire ------------",
   "fire, in end will world the say Some",
   "ice. in say Some",
   "desire of tasted I've what From",
   "fire. favor who those with hold I",
   "",
   "... elided paragraph last ...",
   "",
   "Frost Robert -----------------------"];

foreach ln (in) {
  ln = strtok(ln, " \t");
  array_reverse(ln);
  () = printf("%s\n", strjoin(ln, " "));
}


object ReverseWords extends App {

  """|  ---------- Ice and Fire ------------
     |
     |  fire, in end will world the say Some
     |  ice. in say Some
     |  desire of tasted I've what From
     |  fire. favor who those with hold I
     |
     |  ... elided paragraph last ...
     |
     |  Frost Robert -----------------------  """
    .stripMargin.lines.toList.map{_.split(" ")}.map{_.reverse}
    .map(_.mkString(" "))
    .foreach{println}

}


BEGIN

PROCEDURE ROMAN (INTEGER VALUE NUMBER; STRING(15) RESULT CHARACTERS; INTEGER RESULT LENGTH);
    COMMENT
         Returns the Roman number of an integer between 1 and 3999.
         "MMMDCCCLXXXVIII" (15 characters long) is the longest Roman number under 4000;
    BEGIN
        INTEGER PLACE, POWER;

        PROCEDURE APPEND (STRING(1) VALUE C);
            BEGIN CHARACTERS(LENGTH|1) := C; LENGTH := LENGTH + 1 END;

        PROCEDURE I; APPEND(CASE PLACE OF ("I","X","C","M"));
        PROCEDURE V; APPEND(CASE PLACE OF ("V","L","D"));
        PROCEDURE X; APPEND(CASE PLACE OF ("X","C","M"));

        ASSERT (NUMBER >= 1) AND (NUMBER < 4000);

        CHARACTERS := "               ";
        LENGTH := 0;
        POWER := 1000;
        PLACE := 4;
        WHILE PLACE > 0 DO
            BEGIN
                CASE NUMBER DIV POWER + 1 OF BEGIN
                    BEGIN            END;
                    BEGIN I          END;
                    BEGIN I; I       END;
                    BEGIN I; I; I    END;
                    BEGIN I; V       END;
                    BEGIN V          END;
                    BEGIN V; I       END;
                    BEGIN V; I; I    END;
                    BEGIN V; I; I; I END;
                    BEGIN I; X       END
                END;
                NUMBER := NUMBER REM POWER;
                POWER := POWER DIV 10;
                PLACE := PLACE - 1
            END
    END ROMAN;

INTEGER I;
STRING(15) S;

ROMAN(1, S, I);    WRITE(S, I);
ROMAN(3999, S, I); WRITE(S, I);
ROMAN(3888, S, I); WRITE(S, I);
ROMAN(2009, S, I); WRITE(S, I);
ROMAN(405, S, I);  WRITE(S, I);
END.


toRoman←{
    ⍝ Digits and corresponding values
    ds←((⊢≠⊃)⊆⊢)' M CM D CD C XC L XL X IX V IV I'
    vs←1000, ,100 10 1∘.×9 5 4 1
    ⍝ Input ≤ 0 is invalid
    ⍵≤0:⎕SIGNAL 11
    {   0=d←⊃⍸vs≤⍵:⍬    ⍝ Find highest digit in number
        (d⊃ds),∇⍵-d⊃vs  ⍝ While one exists, add it and subtract from number
    }⍵
}


(for-each
  (lambda (s) (print (string-join (reverse (string-split s #/ +/)))))
  (string-split
    "---------- Ice and Fire ------------

    fire, in end will world the say Some
    ice. in say Some
    desire of tasted I've what From
    fire. favor who those with hold I

    ... elided paragraph last ...

    Frost Robert -----------------------"
    #/[ \r]*\n[ \r]*/))


$ include "seed7_05.s7i";

const array string: lines is [] (
    "---------- Ice and Fire ------------",
    "",
    "fire, in end will world the say Some",
    "ice. in say Some",
    "desire of tasted I've what From",
    "fire. favor who those with hold I",
    "",
    "... elided paragraph last ...",
    "",
    "Frost Robert -----------------------");

const proc: main is func
  local
    var string: line is "";
    var array string: words is 0 times "";
    var integer: index is 0;
  begin
    for line range lines do
      words := split(line, ' ');
      for index range length(words) downto 1 do
        write(words[index] <& " ");
      end for;
      writeln;
    end for;
  end func;


set poem to {{
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------
}}

repeat with each line in poem
	put (each word of it) reversed joined by space
end repeat


------------------ ROMAN INTEGER STRINGS -----------------

-- roman :: Int -> String
on roman(n)
    set kvs to {["M", 1000], ["CM", 900], ["D", 500], ¬
        ["CD", 400], ["C", 100], ["XC", 90], ["L", 50], ¬
        ["XL", 40], ["X", 10], ["IX", 9], ["V", 5], ¬
        ["IV", 4], ["I", 1]}

    script stringAddedValueDeducted
        on |λ|(balance, kv)
            set {k, v} to kv
            set {q, r} to quotRem(balance, v)
            if q > 0 then
                {r, concat(replicate(q, k))}
            else
                {r, ""}
            end if
        end |λ|
    end script

    concat(snd(mapAccumL(stringAddedValueDeducted, n, kvs)))
end roman

--------------------------- TEST -------------------------
on run

    map(roman, [2016, 1990, 2008, 2000, 1666])

    --> {"MMXVI", "MCMXC", "MMVIII", "MM", "MDCLXVI"}
end run

---------------- GENERIC LIBRARY FUNCTIONS ---------------

-- concat :: [[a]] -> [a] | [String] -> String
on concat(xs)
    script append
        on |λ|(a, b)
            a & b
        end |λ|
    end script

    if length of xs > 0 and ¬
        class of (item 1 of xs) is string then
        set unit to ""
    else
        set unit to {}
    end if
    foldl(append, unit, xs)
end concat

-- foldl :: (a -> b -> a) -> a -> [b] -> a
on foldl(f, startValue, xs)
    tell mReturn(f)
        set v to startValue
        set lng to length of xs
        repeat with i from 1 to lng
            set v to |λ|(v, item i of xs, i, xs)
        end repeat
        return v
    end tell
end foldl

-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
    tell mReturn(f)
        set lng to length of xs
        set lst to {}
        repeat with i from 1 to lng
            set end of lst to |λ|(item i of xs, i, xs)
        end repeat
        return lst
    end tell
end map

-- 'The mapAccumL function behaves like a combination of map and foldl;
-- it applies a function to each element of a list, passing an
-- accumulating parameter from left to right, and returning a final
-- value of this accumulator together with the new list.' (see Hoogle)

-- mapAccumL :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])
on mapAccumL(f, acc, xs)
    script
        on |λ|(a, x)
            tell mReturn(f) to set pair to |λ|(item 1 of a, x)
            [item 1 of pair, (item 2 of a) & {item 2 of pair}]
        end |λ|
    end script

    foldl(result, [acc, {}], xs)
end mapAccumL

-- Lift 2nd class handler function into 1st class script wrapper
-- mReturn :: Handler -> Script
on mReturn(f)
    if class of f is script then
        f
    else
        script
            property |λ| : f
        end script
    end if
end mReturn

--  quotRem :: Integral a => a -> a -> (a, a)
on quotRem(m, n)
    {m div n, m mod n}
end quotRem

-- Egyptian multiplication - progressively doubling a list, appending
-- stages of doubling to an accumulator where needed for binary
-- assembly of a target length

-- replicate :: Int -> a -> [a]
on replicate(n, a)
    set out to {}
    if n < 1 then return out
    set dbl to {a}

    repeat while (n > 1)
        if (n mod 2) > 0 then set out to out & dbl
        set n to (n div 2)
        set dbl to (dbl & dbl)
    end repeat
    return out & dbl
end replicate

-- snd :: (a, b) -> b
on snd(xs)
    if class of xs is list and length of xs = 2 then
        item 2 of xs
    else
        missing value
    end if
end snd


DATA.each{|line| line.words.reverse.join(" ").say};

__DATA__
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------


poem := '---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I''ve what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------'.

(poem lines collect: [ :line | ((line splitOn: ' ') reverse) joinUsing: ' '  ]) joinUsing: (String cr).


let lines = split("---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------", "\n");

foreach(lines, function(idx, line) {
	let words = split(line, " ");
	let reverseWords = map(words, function(idx) { return words[sizeof words - idx - 1]; });
	foreach(reverseWords, function(idx, word) {
		printf("%s ", word);
	});

	print();
});


val lines = [
  " ---------- Ice and Fire ------------ ",
  "                                      ",
  " fire, in end will world the say Some ",
  " ice. in say Some                     ",
  " desire of tasted I've what From      ",
  " fire. favor who those with hold I    ",
  "                                      ",
  " ... elided paragraph last ...        ",
  "                                      ",
  " Frost Robert ----------------------- "
]

val revWords = String.concatWith " " o rev o String.tokens Char.isSpace

val () = app (fn line => print (revWords line ^ "\n")) lines


import Foundation

// convenience extension for better clarity
extension String {
    var lines: [String] {
        get {
            return self.componentsSeparatedByCharactersInSet(NSCharacterSet.newlineCharacterSet())
        }
    }
    var words: [String] {
        get {
            return self.componentsSeparatedByCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
        }
    }
}

let input = "---------- Ice and Fire ------------\n\nfire, in end will world the say Some\nice. in say Some\ndesire of tasted I've what From\nfire. favor who those with hold I\n\n... elided paragraph last ...\n\nFrost Robert -----------------------\n"

let output = input.lines.map { $0.words.reverse().joinWithSeparator(" ") }.joinWithSeparator("\n")

print(output)


def input: ['---------- Ice and Fire ------------',
                    '',
                    'fire, in end will world the say Some',
                    'ice. in say Some',
                    'desire of tasted I''ve what From',
                    'fire. favor who those with hold I',
                    '',
                    '... elided paragraph last ...',
                    '',
                    'Frost Robert -----------------------']
;

composer words
  [ <word>* ]
  rule word: <~WS> <WS>?
end words

$input... -> '$ -> words -> $(last..first:-1)...;
' -> !OUT::write


set lines {
    "---------- Ice and Fire ------------"
    ""
    "fire, in end will world the say Some"
    "ice. in say Some"
    "desire of tasted I've what From"
    "fire. favor who those with hold I"
    ""
    "... elided paragraph last ..."
    ""
    "Frost Robert -----------------------"
}
foreach line $lines {
    puts [join [lreverse [regexp -all -inline {\S+} $line]]]
    # This would also work for data this simple:
    ### puts [lreverse $line]
}


while read -a words; do
    for ((i=${#words[@]}-1; i>=0; i--)); do
        printf "%s " "${words[i]}"
    done
    echo
done << END
---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------
END


V rules = [‘rock’ = ‘paper’, ‘scissors’ = ‘rock’, ‘paper’ = ‘scissors’]
V previous = [‘rock’, ‘paper’, ‘scissors’]

L
   V human = input("\nchoose your weapon: ")
   V computer = rules[random:choice(previous)]

   I human C (‘quit’, ‘exit’)
      L.break

   E I human C rules
      previous.append(human)
      print(‘the computer played ’computer, end' ‘; ’)

      I rules[computer] == human
         print(‘yay you win!’)
      E I rules[human] == computer
         print(‘the computer beat you... :(’)
      E
         print(‘it's a tie!’)

   E
      print(‘that's not a valid choice’)


MsgBox % stor(444)

stor(value)
{
  romans = M,CM,D,CD,C,XC,L,XL,X,IX,V,IV,I
  M := 1000
  CM := 900
  D := 500
  CD := 400
  C := 100
  XC := 90
  L := 50
  XL := 40
  X := 10
  IX := 9
  V := 5
  IV := 4
  I := 1
  Loop, Parse, romans, `,
  {
    While, value >= %A_LoopField%
    {
      result .= A_LoopField
      value := value - (%A_LoopField%)
    }
  }
  Return result . "O"
}


Option Explicit

Sub Main()
Dim Lines(9) As String, i&
    'Input
    Lines(0) = "------------- Ice And Fire -------------"
    Lines(1) = ""
    Lines(2) = "fire, in end will world the say Some"
    Lines(3) = "ice. in say Some"
    Lines(4) = "desire of tasted I've what From"
    Lines(5) = "fire. favor who those with hold I"
    Lines(6) = ""
    Lines(7) = "... elided paragraph last ..."
    Lines(8) = ""
    Lines(9) = "Frost Robert -----------------------"
    'Output
    For i = 0 To 9
        Debug.Print ReverseLine(Lines(i), " ")
    Next
End Sub

Private Function ReverseLine(Line As String, Optional Separat As String) As String
Dim T, R, i&, j&, deb&, fin&
    If Len(Line) = 0 Then
        ReverseLine = vbNullString
    Else
        If Separat = "" Then Separat = " "
        T = Split(Line, Separat)
        ReDim R(UBound(T)): j = LBound(T)
        deb = UBound(T): fin = deb / 2
        For i = deb To fin Step -1
            R(j) = T(i)
            R(i) = T(j)
            j = j + 1
        Next i
        ReverseLine = Join(R, Separat)
    End If
End Function


Option Explicit

Dim objFSO, objInFile, objOutFile
Dim srcDir, line

Set objFSO = CreateObject("Scripting.FileSystemObject")

srcDir = objFSO.GetParentFolderName(WScript.ScriptFullName) & "\"

Set objInFile = objFSO.OpenTextFile(srcDir & "In.txt",1,False,0)

Set objOutFile = objFSO.OpenTextFile(srcDir & "Out.txt",2,True,0)

Do Until objInFile.AtEndOfStream
	line = objInFile.ReadLine
	If line = "" Then
		objOutFile.WriteLine ""
	Else
		objOutFile.WriteLine Reverse_String(line)
	End If
Loop

Function Reverse_String(s)
	Dim arr, i
	arr = Split(s," ")
	For i = UBound(arr) To LBound(arr) Step -1
		If arr(i) <> "" Then
			If i = UBound(arr) Then
				Reverse_String = Reverse_String & arr(i)
			Else
				Reverse_String = Reverse_String & " " & arr(i)
			End If
		End If
	Next
End Function

objInFile.Close
objOutFile.Close
Set objFSO = Nothing


fn main() {
    mut n := [
        "---------- Ice and Fire ------------",
        "                                    ",
        "fire, in end will world the say Some",
        "ice. in say Some                    ",
        "desire of tasted I've what From     ",
        "fire. favor who those with hold I   ",
        "                                    ",
        "... elided paragraph last ...       ",
        "                                    ",
        "Frost Robert -----------------------",
    ]
    for i, s in n {
        mut t := s.fields() // tokenize
        // reverse
        last := t.len - 1
        for j, k in t[..t.len/2] {
            t[j], t[last-j] = t[last-j], k
        }
        n[i] = t.join(" ")
    }
    // display result
    for t in n {
        println(t)
    }
}


with Ada.Text_IO; with Ada.Numerics.Float_Random;

procedure Rock_Paper_Scissors is

   package Rand renames Ada.Numerics.Float_Random;
   Gen: Rand.Generator;

   type Choice is (Rock, Paper, Scissors);

   Cnt: array (Choice) of Natural := (1, 1, 1);
     -- for the initialization: pretend that each of Rock, Paper,
     -- and Scissors, has been played once by the human
     -- else the first computer choice would be deterministic

   function Computer_Choice return Choice is
      Random_Number: Natural :=
        Integer(Rand.Random(Gen)
          * (Float(Cnt(Rock)) + Float(Cnt(Paper)) + Float(Cnt(Scissors))));
   begin
      if Random_Number < Cnt(Rock) then
         -- guess the human will choose Rock
         return Paper;
      elsif Random_Number - Cnt(Rock) < Cnt(Paper) then
         -- guess the human will choose Paper
         return Scissors;
      else -- guess the human will choose Scissors
         return Rock;
      end if;
   end Computer_Choice;

   Finish_The_Game: exception;

   function Human_Choice return Choice is
      Done: Boolean := False;
      T: constant String
        := "enter ""r"" for Rock, ""p"" for Paper, or ""s"" for Scissors""!";
      U: constant String
        := "or enter ""q"" to Quit the game";
      Result: Choice;
   begin
      Ada.Text_IO.Put_Line(T);
      Ada.Text_IO.Put_Line(U);
      while not Done loop
         Done := True;
         declare
            S: String := Ada.Text_IO.Get_Line;
         begin
            if S="r" or S="R" then
               Result := Rock;
            elsif S="p" or S = "P" then
               Result := Paper;
            elsif S="s" or S="S" then
               Result := Scissors;
            elsif S="q" or S="Q" then
               raise Finish_The_Game;
            else
               Done := False;
            end if;
         end;
      end loop;
      return Result;
   end Human_Choice;

   type Result is (Human_Wins, Draw, Computer_Wins);

   function "<" (X, Y: Choice) return Boolean is
      -- X < Y if X looses against Y
   begin
      case X is
         when Rock => return  (Y = Paper);
         when Paper => return (Y = Scissors);
         when Scissors => return (Y = Rock);
      end case;
   end "<";

   Score: array(Result) of Natural := (0, 0, 0);

   C,H: Choice;

   Res: Result;

begin
   -- play the game
   loop
      C := Computer_Choice;  -- the computer makes its choice first
      H := Human_Choice;     -- now ask the player for his/her choice
      Cnt(H) := Cnt(H) + 1;  -- update the counts for the AI
      if C < H then
         Res := Human_Wins;
      elsif H < C then
         Res := Computer_Wins;
      else
         Res := Draw;
      end if;
      Ada.Text_IO.Put_Line("COMPUTER'S CHOICE: " & Choice'Image(C)
                             & "       RESULT: " & Result'Image(Res));
      Ada.Text_IO.New_Line;
      Score(Res) := Score(Res) + 1;
   end loop;

exception
   when Finish_The_Game =>
      Ada.Text_IO.New_Line;
      for R in Score'Range loop
         Ada.Text_IO.Put_Line(Result'Image(R) & Natural'Image(Score(R)));
      end loop;
end Rock_Paper_Scissors;


#include<curl/curl.h>
#include<string.h>
#include<stdio.h>

#define MAX_LEN 1000

void searchChatLogs(char* searchString){
	char* baseURL = "http://tclers.tk/conferences/tcl/";
	time_t t;
	struct tm* currentDate;
	char dateString[30],dateStringFile[30],lineData[MAX_LEN],targetURL[100];
	int i,flag;
	FILE *fp;

	CURL *curl;
	CURLcode res;

	time(&t);
	currentDate = localtime(&t);

	strftime(dateString, 30, "%Y-%m-%d", currentDate);
	printf("Today is : %s",dateString);

	if((curl = curl_easy_init())!=NULL){
		for(i=0;i<=10;i++){

		flag = 0;
		sprintf(targetURL,"%s%s.tcl",baseURL,dateString);

		strcpy(dateStringFile,dateString);

		printf("\nRetrieving chat logs from %s\n",targetURL);

		if((fp = fopen("nul","w"))==0){
			printf("Cant's read from %s",targetURL);
		}
		else{
			curl_easy_setopt(curl, CURLOPT_URL, targetURL);
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);

		res = curl_easy_perform(curl);

		if(res == CURLE_OK){
			while(fgets(lineData,MAX_LEN,fp)!=NULL){
				if(strstr(lineData,searchString)!=NULL){
					flag = 1;
					fputs(lineData,stdout);
				}
			}

			if(flag==0)
				printf("\nNo matching lines found.");
		}
		fflush(fp);
		fclose(fp);
		}

		currentDate->tm_mday--;
		mktime(currentDate);
		strftime(dateString, 30, "%Y-%m-%d", currentDate);

	}
	curl_easy_cleanup(curl);

	}
}

int main(int argC,char* argV[])
{
	if(argC!=2)
		printf("Usage : %s <followed by search string, enclosed by \" if it contains spaces>",argV[0]);
	else
		searchChatLogs(argV[1]);
	return 0;
}


(defun c:roman() (romanNumber (getint "\n Enter number > "))
(defun romanNumber (n / uni dec hun tho nstr strlist nlist rom)
  (if (and (> n 0) (<= n 3999))
    (progn
       (setq
         UNI (list "" "I" "II" "III" "IV" "V" "VI" "VII" "VIII" "IX")
         DEC (list "" "X" "XX" "XXX" "XL" "L" "LX" "LXX" "LXXX" "XC")
         HUN (list "" "C" "CC" "CCC" "CD" "D" "DC" "DCC" "DCCC" "CM")
         THO (list "" "M" "MM" "MMM")
         nstr (itoa n)
       )
       (while (> (strlen nstr) 0) (setq strlist (append strlist (list (substr nstr 1 1))) nstr (substr nstr 2 (strlen nstr))))
       (setq nlist (mapcar 'atoi strlist))
       (cond
          ((> n 999)(setq rom(strcat(nth (car nlist) THO)(nth (cadr nlist) HUN)(nth (caddr nlist) DEC) (nth (last nlist)UNI ))))
          ((and (> n 99)(<= n 999))(setq rom(strcat (nth (car nlist) HUN)(nth (cadr nlist) DEC) (nth (last nlist)UNI ))))
          ((and (> n 9)(<= n 99))(setq rom(strcat (nth (car nlist) DEC) (nth (last nlist)UNI ))))
          ((<= n 9)(setq rom(nth (last nlist)UNI)))
          )
        )
        (princ "\nNumber out of range!")
    )
rom
)


# syntax: GAWK -f ROMAN_NUMERALS_ENCODE.AWK
BEGIN {
    leng = split("1990 2008 1666",arr," ")
    for (i=1; i<=leng; i++) {
      n = arr[i]
      printf("%s = %s\n",n,dec2roman(n))
    }
    exit(0)
}
function dec2roman(number,  v,w,x,y,roman1,roman10,roman100,roman1000) {
    number = int(number) # force to integer
    if (number < 1 || number > 3999) { # number is too small | big
      return
    }
    split("I II III IV V VI VII VIII IX",roman1," ")   # 1 2 ... 9
    split("X XX XXX XL L LX LXX LXXX XC",roman10," ")  # 10 20 ... 90
    split("C CC CCC CD D DC DCC DCCC CM",roman100," ") # 100 200 ... 900
    split("M MM MMM",roman1000," ")                    # 1000 2000 3000
    v = (number - (number % 1000)) / 1000
    number = number % 1000
    w = (number - (number % 100)) / 100
    number = number % 100
    x = (number - (number % 10)) / 10
    y = number % 10
    return(roman1000[v] roman100[w] roman10[x] roman1[y])
}


var  lines = [
    "---------- Ice and Fire ------------",
    "                                    ",
    "fire, in end will world the say Some",
    "ice. in say Some                    ",
    "desire of tasted I've what From     ",
    "fire. favor who those with hold I   ",
    "                                    ",
    "... elided paragraph last ...       ",
    "                                    ",
    "Frost Robert -----------------------"
]

for (line in lines) {
    var tokens = line.trim().split(" ")
    tokens = tokens[-1..0]
    System.print(tokens.join(" "))
}


func revWords(x:string=""){
	(x=="")&=>send x+"<br>";
	set sp = x::split(" ");
	send sp::reverse()::join(" ");
}

set lines:array=[
	"---------- Ice and Fire ------------",
	"",
	"fire, in end will world the say Some",
	"ice. in say Some",
	"desire of tasted I've what From",
	"fire. favor who those with hold I",
	"",
	"... elided paragraph last ...",
	"",
	"Frost Robert -----------------------",
];

foreach(v of lines){
	log(revWords(v));
}


string 0;
def LF=$0A, CR=$0D;

proc Reverse(Str, Len); \Reverse order of chars in string
char Str; int Len;
int  I, J, T;
[I:= 0;
J:= Len-1;
while I < J do
    [T:= Str(I);  Str(I):= Str(J);  Str(J):= T;
    I:= I+1;  J:= J-1;
    ];
];

char Str;
int  I, LineBase, WordBase;
[Str:=
"---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------";
I:= 0;
repeat  LineBase:= I;
        loop    [WordBase:= I;
                repeat I:= I+1 until Str(I) <= $20;
                Reverse(@Str(WordBase), I-WordBase);
                if Str(I)=CR or Str(I)=LF or Str(I)=0 then quit;
                I:= I+1;        \skip space
                ];
        Reverse(@Str(LineBase), I-LineBase);
        while Str(I)=CR or Str(I)=LF do I:= I+1;
until   Str(I) = 0;
Text(0, Str);
CrLf(0);
]


data "  ---------- Ice and Fire ------------  "
data "                                        "
data "  fire, in end will world the say Some  "
data "  ice. in say Some                      "
data "  desire of tasted I've what From       "
data "  fire. favor who those with hold I     "
data "                                        "
data "  ... elided paragraph last ...         "
data "                                        "
data "  Frost Robert -----------------------  "
data ""

dim w$(1)

do
    read l$
    if l$ <> "" then
        n = token(l$, w$(), " ")
        for i = n to 1 step -1
            print w$(i), " ";
        next
        print
    else
        break
    end if
loop


text
computer_play(record plays, record beats)
{
    integer a, c, total;
    text s;

    total = plays["rock"] + plays["paper"] + plays["scissors"];
    a = drand(total - 1);
    for (s, c in plays) {
        if (a < c) {
            break;
        }
        a -= c;
    }

    beats[s];
}

integer
main(void)
{
    integer computer, human;
    record beats, plays;
    file f;
    text s;

    computer = human = 0;

    f.stdin;

    beats["rock"] = "paper";
    beats["paper"] = "scissors";
    beats["scissors"] = "rock";

    plays["rock"] = 1;
    plays["paper"] = 1;
    plays["scissors"] = 1;

    while (1) {
        o_text("Your choice [rock/paper/scissors]:\n");
        if (f.line(s) == -1) {
            break;
        }

        if (!plays.key(s)) {
            o_text("Invalid choice, try again\n");
        } else {
            text c;

            c = computer_play(plays, beats);

            o_form("Human: ~, Computer: ~\n", s, c);

            if (s == c) {
                o_text("Draw\n");
            } elif (c == beats[s]) {
                computer += 1;
                o_text("Computer wins\n");
            } else {
                human += 1;
                o_text("Human wins\n");
            }

            plays.up(s);

            o_form("Score: Human: ~, Computer: ~\n", human, computer);
        }
    }

    return 0;
}


BEGIN
    # rock/paper/scissors game                                             #
    # counts of the number of times the player has chosen each move        #
    # we initialise each to 1 so that the total isn't zero when we are     #
    # choosing the computer's first move (as in the Ada version)           #
    INT    r count := 1;
    INT    p count := 1;
    INT    s count := 1;
    # counts of how many games the player and computer have won            #
    INT    player count   := 0;
    INT    computer count := 0;
    print( ( "rock/paper/scissors", newline, newline ) );
    WHILE
        CHAR player move;
        # get the players move - r => rock, p => paper, s => scissors      #
        #                        q => quit                                 #
        WHILE
            print( ( "Please enter your move (r/p/s) or q to quit: " ) );
            read( ( player move, newline ) );
            (   player move /= "r"
            AND player move /= "p"
            AND player move /= "s"
            AND player move /= "q"
            )
        DO
            print( ( "Unrecognised move", newline ) )
        OD;
        # continue playing until the player chooses quit                   #
        player move /= "q"
    DO
        # decide the computer's move based on the player's history         #
        CHAR  computer move;
        INT   move count     = r count + p count + s count;
        # predict player will play rock  if the random number              #
        #     is in the range 0 .. rock / total                            #
        # predict player will play paper if the random number              #
        #     is in the range rock / total .. ( rock + paper ) / total     #
        # predict player will play scissors otherwise                      #
        REAL  r limit        = r count / move count;
        REAL  p limit        = r limit + ( p count / move count );
        REAL  random move    = next random;
        IF    random move < r limit THEN
            # we predict the player will choose rock - we choose paper     #
            computer move := "p"
        ELIF  random move < p limit THEN
            # we predict the player will choose paper - we choose scissors #
            computer move := "s"
        ELSE
            # we predict the player will choose scissors - we choose rock  #
            computer move := "r"
        FI;
        print( ( "You chose: " + player   move, newline ) );
        print( ( "I   chose: " + computer move, newline ) );
        IF   player move = computer move THEN
            # both players chose the same - draw                           #
            print( ( "We draw", newline ) )
        ELSE
            # players chose different moves - there is a winner            #
            IF ( player move = "r" AND computer move = "s" )
            OR ( player move = "p" AND computer move = "r" )
            OR ( player move = "s" AND computer move = "p" )
            THEN
                player count +:= 1;
                print( ( "You win", newline ) )
            ELSE
                computer count +:= 1;
                print( ( "I win",   newline ) )
            FI;
            print( ( "You won: "
                   , whole( player count  , 0 )
                   , ", I won: "
                   , whole( computer count, 0 )
                   , newline
                   )
                 )
        FI;
        IF   player move = "r" THEN
            # player chose rock                                            #
            r count +:= 1
        ELIF player move = "p" THEN
            # player chose paper                                           #
            p count +:= 1
        ELSE
            # player chose scissors                                        #
            s count +:= 1
        FI
    OD;
    print( ( "Thanks for a most enjoyable game", newline ) )
END


#! /usr/bin/env elixir
defmodule Mentions do
  def get(url) do
    {:ok, {{_, 200, _}, _, body}} =
      url
      |> String.to_charlist()
      |> :httpc.request()
    data = List.to_string(body)
    if Regex.match?(~r|<!Doctype HTML.*<Title>URL Not Found</Title>|s, data) do
      {:error, "log file not found"}
    else
      {:ok, data}
    end
  end

  def perg(haystack, needle) do
    haystack
    |> String.split("\n")
    |> Enum.filter(fn x -> String.contains?(x, needle) end)
  end

  def generate_url(n) do
    date_str =
      DateTime.utc_now()
      |> DateTime.to_unix()
      |> (fn x -> x + 60*60*24*n end).()
      |> DateTime.from_unix!()
      |> (fn %{year: y, month: m, day: d} ->
        :io_lib.format("~B-~2..0B-~2..0B", [y, m, d])
      end).()
    "http://tclers.tk/conferences/tcl/#{date_str}.tcl"
  end
end

[needle] = System.argv()
:application.start(:inets)
back = 10
# Elixir does not come standard with time zone definitions, so we add an extra
# day to account for the possible difference between the local and the server
# time.
for i <- -back..1 do
  url = Mentions.generate_url(i)
  with {:ok, haystack} <- Mentions.get(url),
       # If the result is a non-empty list...
       [h | t] <-  Mentions.perg(haystack, needle) do
    IO.puts("#{url}\n------\n#{Enum.join([h | t], "\n")}\n------\n")
  end
end


#!/usr/bin/env fsharpi
let server_tz =
    try
        // CLR on Windows
        System.TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time")
    with
        // Mono
        :? System.TimeZoneNotFoundException ->
            System.TimeZoneInfo.FindSystemTimeZoneById("Europe/Berlin")

let get url =
    let req = System.Net.WebRequest.Create(System.Uri(url))
    use resp = req.GetResponse()
    use stream = resp.GetResponseStream()
    use reader = new System.IO.StreamReader(stream)
    reader.ReadToEnd()

let grep needle (haystack : string) =
    haystack.Split('\n')
    |> Array.toList
    |> List.filter (fun x -> x.Contains(needle))

let genUrl n =
    let day = System.DateTime.UtcNow.AddDays(float n)
    let server_dt = System.TimeZoneInfo.ConvertTimeFromUtc(day, server_tz)
    let timestamp = server_dt.ToString("yyyy-MM-dd")
    sprintf "http://tclers.tk/conferences/tcl/%s.tcl" timestamp

let _ =
    match fsi.CommandLineArgs with
    | [|_; needle|] ->
        let back = 10
        for i in -back .. 0 do
            let url = genUrl i
            let found = url |> get |> grep needle |> String.concat "\n"
            if found <> "" then printfn "%s\n------\n%s\n------\n" url found
            else ()
    | x ->
        printfn "Usage: %s literal" (Array.get x 0)
        System.Environment.Exit(1)


package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"strings"
	"time"
)

func get(url string) (res string, err error) {
	resp, err := http.Get(url)
	if err != nil {
		return "", err
	}
	buf, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "", err
	}
	return string(buf), nil
}

func grep(needle string, haystack string) (res []string) {
	for _, line := range strings.Split(haystack, "\n") {
		if strings.Contains(line, needle) {
			res = append(res, line)
		}
	}
	return res
}

func genUrl(i int, loc *time.Location) string {
	date := time.Now().In(loc).AddDate(0, 0, i)
	return date.Format("http://tclers.tk/conferences/tcl/2006-01-02.tcl")
}

func main() {
	needle := os.Args[1]
	back := -10
	serverLoc, err := time.LoadLocation("Europe/Berlin")
	if err != nil {
		log.Fatal(err)
	}
	for i := back; i <= 0; i++ {
		url := genUrl(i, serverLoc)
		contents, err := get(url)
		if err != nil {
			log.Fatal(err)
		}
		found := grep(needle, contents)
		if len(found) > 0 {
			fmt.Printf("%v\n------\n", url)
			for _, line := range found {
				fmt.Printf("%v\n", line)
			}
			fmt.Printf("------\n\n")
		}
	}
}


text:=Data(0,String,
#<<<
"---------- Ice and Fire ------------

fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I

... elided paragraph last ...

Frost Robert -----------------------");
#<<<

text.pump(11,Data,fcn(s){ // process stripped lines
   s.split(" ").reverse().concat(" ") + "\n" })
   .text.print();


DllCall("AllocConsole")
Write("Welcome to Rock-Paper-Scissors`nMake a choice: ")

cR := cP := cS := 0 ; user choice count
userChoice := Read()
Write("My choice: " . cpuChoice := MakeChoice(1, 1, 1))

Loop
{
	Write(DecideWinner(userChoice, cpuChoice) . "`nMake A Choice: ")
	cR += SubStr(userChoice, 1, 1) = "r", cP += InStr(userChoice, "P"), cS += InStr(userChoice, "S")
	userChoice := Read()
	Write("My Choice: " . cpuChoice := MakeChoice(cR, cP, cS))
}

MakeChoice(cR, cP, cS){
	; parameters are number of times user has chosen each item
	total := cR + cP + cS

	Random, rand, 0.0, 1.0
	if (rand >= 0 and rand <= cR / total)
		return "Paper"
	else if (rand > cR / total and rand <= (cR + cP) / total)
		return "Scissors"
	else
		return "Rock"
}

DecideWinner(user, cpu){
	user := SubStr(user, 1, 1), cpu := SubStr(cpu, 1, 1)
	if (user = cpu)
		return "`nTie!"
	else if (user = "r" and cpu = "s") or (user = "p" and cpu = "r") or (user = "s" and cpu = "p")
		return "`nYou Win!"
	else
		return "`nI Win!"
}

Read(){
	FileReadLine, a, CONIN$, 1
	return a
}
Write(txt){
	FileAppend, % txt, CONOUT$
}


using Dates, TimeZones, HTTP, Printf

function geturlbyday(n)
    d = DateTime(now(tz"Europe/Berlin")) + Day(n)  # n should be <= 0
    uri = @sprintf("http://tclers.tk/conferences/tcl/%04d-%02d-%02d.tcl",
        year(d), month(d), day(d))
    return uri, String(HTTP.request("GET", uri).body)
end

function searchlogs(text = ARGS[1], daysback = 9)
    for n in -daysback:0
        fname, searchtext = geturlbyday(n)
        println("$fname\n------")
        for line in split(searchtext, "\n")
            if findfirst(text, line) != nothing
                println(line)
            end
        end
        println("------\n")
    end
end

if length(ARGS) != 1
    println("Usage: type search phrase in quotes as an argument.")
else
    searchlogs()
end


matchFrom[url_String, str_String] := Select[StringSplit[Import[url, "String"], "\n"], StringMatchQ[str]]
getLogLinks[n_] :=
 Select[Import["http://tclers.tk/conferences/tcl/", "Hyperlinks"],
     First[
     StringCases[#1, "tcl/" ~~ date__ ~~ ".tcl" :> DateDifference[DateObject[URLDecode[date], TimeZone -> "Europe/Berlin"], Now]]] <=
         Quantity[n, "Days"] & ]
searchLogs[str_String] := Block[{data},
  Map[
   (data = matchFrom[#, str];
     If[Length[data] > 0,
      Print /@ Join[{#, "-----"}, data, {"----\n"}]]) &,
   getLogLinks[10]]]
searchLogs["*lazy*"];


import httpclient, os, re, strformat, strutils, sugar, times

const Template = "'http://tclers.tk/conferences/tcl/'yyyy-MM-dd'.tcl'"

proc get(url: string): string =
  var client = newHttpClient()
  result = client.getContent(url)
  if result.match(re"<!Doctype HTML[\s\S]*<Title>URL Not Found</Title>"):
    result = ""
  client.close()

let today = now()
const Back = 10
if paramCount() != 1:
  quit "Wrong number of parameters", QuitFailure
let needle = paramStr(1)
for i in -Back..1:
  let day = today + initTimeInterval(days = i)
  let url = day.format(Template)
  let haystack = url.get()
  if haystack.len != 0:
    let mentions = collect(newSeq):
                     for line in haystack.splitLines(keepEol = true):
                       if needle in line:
                         line
    if mentions.len > 0:
      echo &"{url}\n------\n{mentions.join()}------\n"


# 20210316 Perl programming solution

use strict;
use warnings;
use Time::Piece;
use IO::Socket::INET;
use HTTP::Tiny;
use feature 'say';

my $needle = shift @ARGV // '';
my @haystack = ();
my $page = '';

# 10 days before today
my $begin =  Time::Piece->new - 10 * Time::Piece::ONE_DAY;
say "         Executed at: ", Time::Piece->new;
say "Begin searching from: $begin";

for (my $date = $begin ; Time::Piece->new > $date ; $date += Time::Piece::ONE_DAY) {
   $page .= HTTP::Tiny->new()->get( 'http://tclers.tk/conferences/tcl/'.$date->strftime('%Y-%m-%d').'.tcl')->{content};
}

# process pages
my @lines = split /\n/, $page;
for (@lines) { push @haystack, $_ if substr($_, 0, 13) =~ m/^m \d\d\d\d-\d\d-\d\dT/ }

# print the first and last line of the haystack
say "First and last lines of the haystack:";
say $haystack[0] and say $haystack[-1];

say "Needle: ", $needle;
say  '-' x 79;

# find and print needle lines
for (@haystack) { say $_ if (index($_, $needle) != -1) }


print 1666+" = "+convert$(1666)
print 2008+" = "+convert$(2008)
print 1001+" = "+convert$(1001)
print 1999+" = "+convert$(1999)

function convert$(value)
convert$=""
arabic = {1000, 900, 500, 400, 100, 90, 50,  40,  10,  9,  5,   4,  1 }
roman$ = {"M", "CM", "D","CD", "C","XC","L","XL","X","IX","V","IV","I"}
   for i = 0 to 12
           while value >= arabic[i]
	    convert$ += roman$[i]
	    value  = value - arabic[i]
	 end while
    next i
end function


@echo off
setlocal enabledelayedexpansion

set cnt=0&for %%A in (1000,900,500,400,100,90,50,40,10,9,5,4,1) do (set arab!cnt!=%%A&set /a cnt+=1)
set cnt=0&for %%R in (M,CM,D,CD,C,XC,L,XL,X,IX,V,IV,I) do (set rom!cnt!=%%R&set /a cnt+=1)

::Testing
call :toRoman 2009
echo 2009 = !result!
call :toRoman 1666
echo 1666 = !result!
call :toRoman 3888
echo 3888 = !result!
pause>nul
exit/b 0

::The "function"...
:toRoman
set value=%1
set result=

for /l %%i in (0,1,12) do (
	set a=%%i
	call :add_val
)
goto :EOF

:add_val
if !value! lss !arab%a%! goto :EOF
set result=!result!!rom%a%!
set /a value-=!arab%a%!
goto add_val


RPS()

Func RPS()
	Local $ai_Played_games[4]
	$ai_Played_games[0] = 3
	For $I = 1 To 3
		$ai_Played_games[$I] = 1
	Next
	$RPS = GUICreate("Rock Paper Scissors", 338, 108, 292, 248)
	$Rock = GUICtrlCreateButton("Rock", 8, 8, 113, 25, 131072)
	$Paper = GUICtrlCreateButton("Paper", 8, 40, 113, 25, 131072)
	$Scissors = GUICtrlCreateButton("Scissors", 8, 72, 113, 25, 131072)
	$Label1 = GUICtrlCreateLabel("W:", 136, 8, 18, 17)
	$Wins = GUICtrlCreateLabel("0", 160, 8, 36, 17)
	$Label3 = GUICtrlCreateLabel("L:", 208, 8, 13, 17)
	$Looses = GUICtrlCreateLabel("0", 224, 8, 36, 17)
	$Label5 = GUICtrlCreateLabel("D:", 272, 8, 15, 17)
	$Deuce = GUICtrlCreateLabel("0", 296, 8, 36, 17)
	$Displaybutton = GUICtrlCreateButton("", 136, 48, 193, 49, 131072)
	GUICtrlSetState($ai_Played_games, 128)
	GUISetState(@SW_SHOW)
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case -3
				Exit
			Case $Rock
				$Ret = _RPS_Eval(1, $ai_Played_games)
				GUICtrlSetData($Displaybutton, $Ret)
				If $Ret = "Deuce" Then
					GUICtrlSetData($Deuce, Guictrlread($Deuce)+1)
				Elseif $Ret = "You Loose" Then
					GUICtrlSetData($Looses, Guictrlread($Looses)+1)
				Elseif $Ret = "You Win" Then
					GUICtrlSetData($Wins, Guictrlread($Wins)+1)
				EndIf
			Case $Paper
				$Ret = _RPS_Eval(2, $ai_Played_games)
				GUICtrlSetData($Displaybutton, $Ret)
				If $Ret = "Deuce" Then
					GUICtrlSetData($Deuce, Guictrlread($Deuce)+1)
				Elseif $Ret = "You Loose" Then
					GUICtrlSetData($Looses, Guictrlread($Looses)+1)
				Elseif $Ret = "You Win" Then
					GUICtrlSetData($Wins, Guictrlread($Wins)+1)
				EndIf
			Case $Scissors
				$Ret = _RPS_Eval(3, $ai_Played_games)
				GUICtrlSetData($Displaybutton, $Ret)
				If $Ret = "Deuce" Then
					GUICtrlSetData($Deuce, Guictrlread($Deuce)+1)
				Elseif $Ret = "You Loose" Then
					GUICtrlSetData($Looses, Guictrlread($Looses)+1)
				Elseif $Ret = "You Win" Then
					GUICtrlSetData($Wins, Guictrlread($Wins)+1)
				EndIf
		EndSwitch
	WEnd

EndFunc   ;==>RPS

Func _RPS_Eval($i_Player_Choose, $ai_Played_games)
	Local $i_choice = 1
	$i_rnd = Random(1, 1000, 1)
	$i_choose_1 = ($ai_Played_games[1] / $ai_Played_games[0] * 1000)
	$i_choose_2 = ($ai_Played_games[2] / $ai_Played_games[0] * 1000)
	$i_choose_3 = ($ai_Played_games[3] / $ai_Played_games[0] * 1000)
	If $i_rnd < $i_choose_1 Then
		$i_choice = 2
	ElseIf $i_rnd < $i_choose_1 + $i_choose_2 And $i_rnd > $i_choose_1 Then
		$i_choice = 3
	ElseIf $i_rnd < $i_choose_1 + $i_choose_2 + $i_choose_3 And $i_rnd > $i_choose_1 + $i_choose_2 Then
		$i_choice = 1
	EndIf
	$ai_Played_games[0] += 1
	If $i_Player_Choose = 1 Then
		$ai_Played_games[1] += 1
		If $i_choice = 1 Then Return "Deuce"
		If $i_choice = 2 Then Return "You Loose"
		If $i_choice = 3 Then Return "You Win"
	ElseIf $i_Player_Choose = 2 Then
		$ai_Played_games[2] += 1
		If $i_choice = 2 Then Return "Deuce"
		If $i_choice = 3 Then Return "You Loose"
		If $i_choice = 1 Then Return "You Win"
	ElseIf $i_Player_Choose = 3 Then
		$ai_Played_games[3] += 1
		If $i_choice = 3 Then Return "Deuce"
		If $i_choice = 1 Then Return "You Loose"
		If $i_choice = 2 Then Return "You Win"
	EndIf
EndFunc   ;==>_RPS_Eval


include builtins\libcurl.e
atom curl = NULL

function download(string url)
    if curl=NULL then
        curl_global_init()
        curl = curl_easy_init()
    end if
    curl_easy_setopt(curl, CURLOPT_URL, url)
    object res = curl_easy_perform_ex(curl)
    if integer(res) then
        printf(1,"libcurl error %d (%s)\n",{res,curl_easy_strerror(res)})
        return ""
    end if
    return res
end function

function grep(string needle, haystack)
    sequence lines = split(haystack,"\n"),
             res = {}
    for i=1 to length(lines) do
        if match(needle,lines[i]) then
            res = append(res,lines[i])
        end if
    end for
    if res={} then res = {"no occurences"} end if
    return res
end function

include builtins\timedate.e

function gen_url(integer i, string timezone)
    timedate td = set_timezone(date(),timezone)
    td = adjust_timedate(td,timedelta(days:=i))
    return format_timedate(td,"'http://tclers.tk/conferences/tcl/'YYYY-MM-DD'.tcl'")
end function

sequence cl = command_line()
string needle = "github"
integer days = 10
if length(cl)>=3 then
    needle := cl[3]
    if length(cl)>=4 then
        days := to_integer(cl[4])
        if days=0 or length(cl)>=5 then ?9/0 end if
    end if
end if
for i=-days to 0 do
    string url := gen_url(i, "CEST"),
           contents = download(url)
    if contents="" then exit end if
    ?url
    printf(1,"%s\n",join(grep(needle,contents),"\n"))
end for


#! /usr/bin/env python3
import datetime
import re
import urllib.request
import sys

def get(url):
    with urllib.request.urlopen(url) as response:
       html = response.read().decode('utf-8')
    if re.match(r'<!Doctype HTML[\s\S]*<Title>URL Not Found</Title>', html):
        return None
    return html

def main():
    template = 'http://tclers.tk/conferences/tcl/%Y-%m-%d.tcl'
    today = datetime.datetime.utcnow()
    back = 10
    needle = sys.argv[1]
    # Since Python does not come standard with time zone definitions, add an
    # extra day to account for the possible difference between the local and the
    # server time.
    for i in range(-back, 2):
        day = today + datetime.timedelta(days=i)
        url = day.strftime(template)
        haystack = get(url)
        if haystack:
            mentions = [x for x in haystack.split('\n') if needle in x]
            if mentions:
                print('{}\n------\n{}\n------\n'
                          .format(url, '\n'.join(mentions)))

main()


get "libhdr"

let toroman(n, v) = valof
$(  let extract(n, val, rmn, v) = valof
    $(  while n >= val
        $(  n := n - val;
            for i=1 to rmn%0 do v%(v%0+i) := rmn%i
            v%0 := v%0 + rmn%0
        $)
        resultis n
    $)

    v%0 := 0
    n := extract(n, 1000, "M",  v)
    n := extract(n,  900, "CM", v)
    n := extract(n,  500, "D",  v)
    n := extract(n,  400, "CD", v)
    n := extract(n,  100, "C",  v)
    n := extract(n,   90, "XC", v)
    n := extract(n,   50, "L",  v)
    n := extract(n,   40, "XL", v)
    n := extract(n,   10, "X",  v)
    n := extract(n,    9, "IX", v)
    n := extract(n,    5, "V",  v)
    n := extract(n,    4, "IV", v)
    n := extract(n,    1, "I",  v)
    resultis v
$)

let show(n) be
$(  let v = vec 50
    writef("%I4 = %S*N", n, toroman(n, v))
$)

let start() be
$(  show(1666)
    show(2008)
    show(1001)
    show(1999)
    show(3888)
    show(2021)
$)


#!/bin/bash
echo "What will you choose? [rock/paper/scissors]"
read response
aiThought=$(echo $[ 1 + $[ RANDOM % 3  ]])
case $aiThought in
	1) 	 aiResponse="rock"   ;;
	2) 	 aiResponse="paper" ;;
	3)  	 aiResponse="scissors"  ;;
esac
echo "AI - $aiResponse"
responses="$response$aiResponse"
case $responses in
	rockrock)  isTie=1  ;;
	rockpaper)  playerWon=0  ;;
	rockscissors)  playerWon=1  ;;
	paperrock)  playerWon=1  ;;
	paperpaper)  isTie=1  ;;
	paperscissors)  playerWon=0  ;;
	scissorsrock)  playerWon=0  ;;
	scissorspaper)  playerWon=1  ;;
	scissorsscissors)  isTie=1  ;;
esac
if [[ $isTie == 1 ]] ; then echo "It's a tie!" && exit 1 ; fi
if [[ $playerWon == 0 ]] ; then echo "Sorry, $aiResponse beats $response , try again.." && exit 1 ; fi
if [[ $playerWon == 1 ]] ; then echo "Good job, $response beats $aiResponse!" && exit 1 ; fi


DIM pPLchoice(1 TO 3) AS INTEGER, pCMchoice(1 TO 3) AS INTEGER
DIM choices(1 TO 3) AS STRING
DIM playerwins(1 TO 3) AS INTEGER
DIM playerchoice AS INTEGER, compchoice AS INTEGER
DIM playerwon AS INTEGER, compwon AS INTEGER, tie AS INTEGER
DIM tmp AS INTEGER

' Do it this way for QBasic; FreeBASIC supports direct array assignment.
DATA "rock", "paper", "scissors"
FOR tmp = 1 TO 3
    READ choices(tmp)
NEXT
DATA 3, 1, 2
FOR tmp = 1 TO 3
    READ playerwins(tmp)
NEXT

RANDOMIZE TIMER

DO
    ' Computer chooses first to ensure there's no "cheating".
    compchoice = INT(RND * (pPLchoice(1) + pPLchoice(2) + pPLchoice(3) + 3))
    SELECT CASE compchoice
        CASE 0 TO (pPLchoice(1))
            ' Player past choice: rock; choose paper.
            compchoice = 2
        CASE (pPLchoice(1) + 1) TO (pPLchoice(1) + pPLchoice(2) + 1)
            ' Player past choice: paper; choose scissors.
            compchoice = 3
        CASE (pPLchoice(1) + pPLchoice(2) + 2) TO (pPLchoice(1) + pPLchoice(2) + pPLchoice(3) + 2)
            ' Player past choice: scissors; choose rock.
            compchoice = 1
    END SELECT

    PRINT "Rock, paper, or scissors ";
    DO
        PRINT "[1 = rock, 2 = paper, 3 = scissors, 0 to quit]";
        INPUT playerchoice
    LOOP WHILE (playerchoice < 0) OR (playerchoice > 3)

    IF 0 = playerchoice THEN EXIT DO

    pCMchoice(compchoice) = pCMchoice(compchoice) + 1
    pPLchoice(playerchoice) = pPLchoice(playerchoice) + 1
    PRINT "You chose "; choices(playerchoice); " and I chose "; choices(compchoice); ". ";
    IF (playerchoice) = compchoice THEN
        PRINT "Tie!"
        tie = tie + 1
    ELSEIF (compchoice) = playerwins(playerchoice) THEN
        PRINT "You won!"
        playerwon = playerwon + 1
    ELSE
        PRINT "I won!"
        compwon = compwon + 1
    END IF
LOOP

PRINT "Some useless statistics:"
PRINT "You won "; STR$(playerwon); " times, and I won "; STR$(compwon); " times; "; STR$(tie); " ties."
PRINT             ,   choices(1),   choices(2),   choices(3)
PRINT "You chose:", pPLchoice(1), pPLchoice(2), pPLchoice(3)
PRINT "  I chose:", pCMchoice(1), pCMchoice(2), pCMchoice(3)


#lang racket
(require net/url)
(require racket/date)

;; generate archive url from specified number of days in the past
(define (generate-url days-ago)
  (putenv "TZ" "Europe/Berlin") ; this works for Linux
  (let* [(today (current-date))
         (past (seconds->date (- (date->seconds today) (* days-ago 60 60 24))))
         (date-str (string-append
                    (~r (date-year past) #:min-width 4 #:pad-string "0") ; 4 digit year
                    "-"
                    (~r (date-month past) #:min-width 2 #:pad-string "0") ; 2 digit month
                    "-"
                    (~r (date-day past) #:min-width 2 #:pad-string "0"))) ; 2 digit day
         (url (string-append "http://tclers.tk/conferences/tcl/" date-str ".tcl"))]
    url))

;; retrieve content of url as a list of strings
(define (get-content-of-url url-string)
  (let [(st (open-output-string))]
    (copy-port (get-pure-port (string->url url-string)
                              #:redirections 100)
               st)
    (string-split  (get-output-string st) "\n"))) ; divide on line breaks

;; from a list of strings, return a list of those containing the search string
(define (get-matches lines search-string)
  (define (internal-get-matches lines search-string results)
    (cond
      ((empty? lines) results)
      (else (internal-get-matches (cdr lines)
                                  search-string
                                  (if (string-contains? (car lines) search-string)
                                      (append results (list (car lines)))
                                      results)))))
  (internal-get-matches lines search-string (list)))

;; display last 10 days worth of archives that contain matches to the search string
(define (display-matches-for-last-10-days search-string)
  ;; get archives from 9 days ago until today
  (for/list ([i (range 9 -1 -1)])
    (let* ([url (generate-url i)]
           [matches (get-matches (get-content-of-url url) search-string)])
      (cond [(not (empty? matches))
             (begin
               (display url)(newline)
               (display "------\n")
               (for/list ([line matches]) (display line)(newline))
               (display "------\n"))]))))

;; use the first command line argument as the search string
;; display usage info if no search string is provided
(cond ((= 0 (vector-length (current-command-line-arguments))) (display "USAGE: chat_history <search term>\n"))
      (else (display-matches-for-last-10-days (vector-ref (current-command-line-arguments) 0))))


⟨ToRoman⇐R⟩ ← {
  ds ← 1↓¨(¯1+`⊏⊸=)⊸⊔" I IV V IX X XL L XC C CD D CM M"
  vs ← 1e3∾˜ ⥊1‿4‿5‿9×⌜˜10⋆↕3
  R ⇐ {
    𝕨𝕊0: "";
    (⊑⟜ds∾·𝕊𝕩-⊑⟜vs) 1-˜⊑vs⍋𝕩
  }
}


@echo off
setlocal enabledelayedexpansion

set choice1=rock
set choice2=paper
set choice3=scissors
set freq1=0
set freq2=0
set freq3=0
set games=0
set won=0
set lost=0
set tie=0

:start
cls
echo Games - %games% : Won - %won% : Lost - %lost% : Ties - %tie%
choice /c RPS /n /m "[R]ock, [P]aper or [S]cissors? "

set choice=%errorlevel%
rem used [1,1000] as interval for random
if %games% equ 0 (
    rem at the beginning, there's no bias for each choice
    set /a "rocklimit=1000 / 3"
    set /a "scissorslimit=1000 * 2 / 3"
) else (
    set /a "rocklimit=1000 * %freq3% / %games%"
    set /a "scissorslimit=1000 * (%freq1% + %freq3%) / %games%"
)
set /a "randchoice=%random% %% 1000 + 1"
set compchoice=2
if %randchoice% geq %scissorslimit% set compchoice=3
if %randchoice% leq %rocklimit% set compchoice=1

cls
echo Player: !choice%choice%! ^|vs^| Computer: !choice%compchoice%!
goto %compchoice%

:1
if %choice%==1 goto tie
if %choice%==2 goto win
if %choice%==3 goto loss

:2
if %choice%==1 goto loss
if %choice%==2 goto tie
if %choice%==3 goto win

:3
if %choice%==1 goto win
if %choice%==2 goto loss
if %choice%==3 goto tie

:win
set /a "won+=1"
echo Player wins^!
goto end

:loss
set /a "lost+=1"
echo Computer Wins^!
goto end

:tie
set /a "tie+=1"
echo Tie^!
goto end

:end
set /a "games+=1"
set /a "freq%choice%+=1"
pause
goto start


my $needle = @*ARGS.shift // '';
my @haystack;

# 10 days before today, Zulu time
my $begin = DateTime.new(time).utc.earlier(:10days);
say "         Executed at: ", DateTime.new(time).utc;
say "Begin searching from: $begin";

# Today - 10 days through today
for $begin.Date .. DateTime.now.utc.Date -> $date {

    # connect to server, use a raw socket
    my $http = IO::Socket::INET.new(:host('tclers.tk'), :port(80));

    # request file
    $http.print: "GET /conferences/tcl/{$date}.tcl HTTP/1.0\n\n";

    # retrieve file
    my @page = $http.lines;

    # remove header
    @page.splice(0, 8);

    # concatenate multi-line entries to a single line
    while @page {
        if @page[0].substr(0, 13) ~~ m/^'m '\d\d\d\d'-'\d\d'-'\d\d'T'/ {
            @haystack.push: @page.shift;
        }
        else {
            @haystack.tail ~= '␤' ~ @page.shift;
        }
    }

    # close socket
    $http.close;
}

# ignore times before 10 days ago
@haystack.shift while @haystack[0].substr(2, 22) lt $begin.Str;

# print the first and last line of the haystack
say "First and last lines of the haystack:";
.say for |@haystack[0, *-1];
say "Needle: ", $needle;
say  '-' x 79;

# find and print needle lines
.say if .contains( $needle ) for @haystack;


#! /usr/bin/env ruby
require 'net/http'
require 'time'

def gen_url(i)
  day = Time.now + i*60*60*24
  # Set the time zone in which to format the time, per
  # https://coderwall.com/p/c7l82a/create-a-time-in-a-specific-timezone-in-ruby
  old_tz = ENV['TZ']
  ENV['TZ'] = 'Europe/Berlin'
  url = day.strftime('http://tclers.tk/conferences/tcl/%Y-%m-%d.tcl')
  ENV['TZ'] = old_tz
  url
end

def main
  back = 10
  needle = ARGV[0]
  (-back..0).each do |i|
    url = gen_url(i)
    haystack = Net::HTTP.get(URI(url)).split("\n")
    mentions = haystack.select { |x| x.include? needle }
    if !mentions.empty?
      puts "#{url}\n------\n#{mentions.join("\n")}\n------\n"
    end
  end
end

main


( ( encode
  =   indian roman cifr tenfoldroman letter tenfold
    .   !arg:#?indian
      & :?roman
      &   whl
        ' ( @(!indian:#%?cifr ?indian)
          & :?tenfoldroman
          &   whl
            ' ( !roman:%?letter ?roman
              &     !tenfoldroman
                    (       (I.X)
                            (V.L)
                            (X.C)
                            (L.D)
                            (C.M)
                        : ? (!letter.?tenfold) ?
                      & !tenfold
                    | "*"
                    )
                : ?tenfoldroman
              )
          & !tenfoldroman:?roman
          & ( !cifr:9&!roman I X:?roman
            |   !cifr:~<4
              &     !roman
                    (!cifr:4&I|)
                    V
                : ?roman
              & !cifr+-5:?cifr
              & ~
            |   whl
              ' ( !cifr+-1:~<0:?cifr
                & !roman I:?roman
                )
            )
          )
      & ( !roman:? "*" ?&~`
        | str$!roman
        )
  )
& 1990 2008 1666 3888 3999 4000:?NS
&   whl
  ' ( !NS:%?N ?NS
    &   out
      $ ( encode$!N:?K&!N !K
        | str$("Can't convert " !N " to Roman numeral")
        )
    )
);


#include <stdio.h>

int main() {
    int arabic[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};

    // There is a bug: "XL\0" is translated into sequence 58 4C 00 00, i.e. it is 4-bytes long...
    // Should be "XL" without \0 etc.
    //
    char roman[13][3] = {"M\0", "CM\0", "D\0", "CD\0", "C\0", "XC\0", "L\0", "XL\0", "X\0", "IX\0", "V\0", "IV\0", "I\0"};
    int N;

    printf("Enter arabic number:\n");
    scanf("%d", &N);
    printf("\nRoman number:\n");

    for (int i = 0; i < 13; i++) {
        while (N >= arabic[i]) {
            printf("%s", roman[i]);
            N -= arabic[i];
        }
    }
    return 0;
}


PRINT"Welcome to the game of rock-paper-scissors"
PRINT "Each player guesses one of these three, and reveals it at the same time."
PRINT "Rock blunts scissors, which cut paper, which wraps stone."
PRINT "If both players choose the same, it is a draw!"
PRINT "When you've had enough, choose Q."
DIM rps%(2),g$(3)
g$()="rock","paper","scissors"
total%=0
draw%=0
pwin%=0
cwin%=0
c%=RND(3)
PRINT"What is your move (press R, P, or S)?"
REPEAT
  REPEAT q$=GET$ UNTIL INSTR("RPSrpsQq",q$)>0
  g%=(INSTR("RrPpSsQq",q$)-1) DIV 2
  IF g%>2 THEN PROCsummarise:END
  total%+=1
  rps%(g%)+=1
  PRINT"You chose ";g$(g%);" and I chose ";g$(c%);
  CASE g%-c% OF
    WHEN 0:
      PRINT ". It's a draw"
      draw%+=1
    WHEN 1,-2:
      PRINT ". You win!"
      pwin%+=1
    WHEN -1,2:
      PRINT ". I win!"
      cwin%+=1
    ENDCASE
  c%=FNmove(rps%(),total%)
UNTIL FALSE
END
:
DEFPROCsummarise
PRINT "You won ";pwin%;", and I won ";cwin%;". There were ";draw%;" draws"
PRINT "Thanks for playing!"
ENDPROC
:
DEFFNmove(p%(),t%)
LOCAL r%
r%=RND(total%)
IF r%<=p%(0) THEN =1
IF r%<=p%(0)+p%(1) THEN =2
=0


#include <stdio.h>
#include <stdlib.h>
#define LEN 3

/* pick a random index from 0 to n-1, according to probablities listed
   in p[] which is assumed to have a sum of 1. The values in the probablity
   list matters up to the point where the sum goes over 1 */
int rand_idx(double *p, int n)
{
	double s = rand() / (RAND_MAX + 1.0);
	int i;
	for (i = 0; i < n - 1 && (s -= p[i]) >= 0; i++);
	return i;
}

int main()
{
	int user_action, my_action;
	int user_rec[] = {0, 0, 0};
	const char *names[] = { "Rock", "Paper", "Scissors" };
	char str[2];
	const char *winner[] = { "We tied.", "Meself winned.", "You win." };
	double  p[LEN] = { 1./3, 1./3, 1./3 };

	while (1) {
		my_action = rand_idx(p,LEN);

		printf("\nYour choice [1-3]:\n"
			"  1. Rock\n  2. Paper\n  3. Scissors\n> ");

		/* scanf is a terrible way to do input.  should use stty and keystrokes */
		if (!scanf("%d", &user_action)) {
			scanf("%1s", str);
			if (*str == 'q') {
				printf("Your choices [rock : %d , paper :  %d , scissors %d] ",user_rec[0],user_rec[1], user_rec[2]);
				return 0;
			}
			continue;
		}
		user_action --;
		if (user_action > 2 || user_action < 0) {
			printf("invalid choice; again\n");
			continue;
		}
		printf("You chose %s; I chose %s. %s\n",
			names[user_action], names[my_action],
			winner[(my_action - user_action + 3) % 3]);

		user_rec[user_action]++;
	}
}


import java.net.Socket
import java.net.URL
import java.time
import java.time.format
import java.time.ZoneId
import java.util.Scanner
import scala.collection.JavaConverters._

def get(rawUrl: String): List[String] = {
    val url = new URL(rawUrl)
    val port = if (url.getPort > -1) url.getPort else 80
    val sock = new Socket(url.getHost, port)
    sock.getOutputStream.write(
        s"GET /${url.getPath()} HTTP/1.0\n\n".getBytes("UTF-8")
    )
    new Scanner(sock.getInputStream).useDelimiter("\n").asScala.toList
}

def genUrl(n: Long) = {
    val date = java.time.ZonedDateTime
        .now(ZoneId.of("Europe/Berlin"))
        .plusDays(n)
        .format(java.time.format.DateTimeFormatter.ISO_LOCAL_DATE)
    s"http://tclers.tk/conferences/tcl/$date.tcl"
}

val back = 10
val literal = args(0)
for (i <- -back to 0) {
    val url = genUrl(i)
    print(get(url).filter(_.contains(literal)) match {
        case List() => ""
        case x => s"$url\n------\n${x.mkString("\n")}\n------\n\n"
    })
}


CommandLineHandler subclass: #ChatHistorySearchCommandLineHandler
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'RosettaCode'!

!ChatHistorySearchCommandLineHandler methodsFor: 'activation' stamp: 'EduardoPadoan 1/27/2019 15:18'!
activate
	self searchHistoryFor: self arguments first.
	self quit! !

!ChatHistorySearchCommandLineHandler methodsFor: 'commands' stamp: 'EduardoPadoan 1/27/2019 17:01'!
searchHistoryFor: aString
	| today startDate |

	"XXX Doesn't account for DST"
	today := DateAndTime now offset: 1 hours.
	startDate := today - 10 days.

	startDate to: today by: 1 days do: [ :targetDate |
		| url response |

		url := String streamContents: [ :aStream |
			aStream nextPutAll: 'http://tclers.tk/conferences/tcl/'.
			targetDate printYMDOn: aStream.
			aStream nextPutAll: '.tcl'.
		].

		response := ZnEasy get: url.

		response contents asString linesDo: [ :line |
			(line asLowercase includesSubstring: aString asLowercase) ifTrue: [
				self stdout print: line; lf.
			]
		]
	]! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

ChatHistorySearchCommandLineHandler class
	instanceVariableNames: ''!

!ChatHistorySearchCommandLineHandler class methodsFor: 'accessing' stamp: 'EduardoPadoan 1/27/2019 14:53'!
description
	^ 'Look for a pattern in the TCL chat history'! !

!ChatHistorySearchCommandLineHandler class methodsFor: 'accessing' stamp: 'EduardoPadoan 1/27/2019 14:50'!
commandName
	^ 'searchHistory'! !


using System;
class Program
{
    static uint[] nums = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };
    static string[] rum = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };

    static string ToRoman(uint number)
    {
        string value = "";
        for (int i = 0; i < nums.Length && number != 0; i++)
        {
            while (number >= nums[i])
            {
                number -= nums[i];
                value += rum[i];
            }
        }
        return value;
    }

    static void Main()
    {
        for (uint number = 1; number <= 1 << 10; number *= 2)
        {
            Console.WriteLine("{0} = {1}", number, ToRoman(number));
        }
    }
}