langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,11 @@
; here-document.lsp
; oofoe 2012-01-19
; http://rosettacode.org/wiki/Here_document
(print (format [text]
Blast it %s! I'm a %s,
not a %s!
--- %s
[/text] "James" "magician" "doctor" "L. McCoy"))
(exit)

View file

@ -0,0 +1,6 @@
my $color = 'green';
my $text = qq :to 'EOT';
some line
color: $color
last line
EOT

View file

@ -0,0 +1,11 @@
my $contrived_example = 'Dylan';
sub freewheelin() {
print q :to 'QUOTE', '-- ', qq :to 'AUTHOR';
I'll let you be in my dream,
if I can be in yours.
QUOTE
Bob $contrived_example
AUTHOR
}
freewheelin;

View file

@ -0,0 +1,17 @@
$XMLdata=@"
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<servicing>
<package action="configure">
<assemblyIdentity name="Microsoft-Windows-Foundation-Package" version="${strFullVersion}" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="" />
<selection name="RemoteServerAdministrationTools" state="true" />
<selection name="RemoteServerAdministrationTools-Roles-AD" state="true" />
<selection name="RemoteServerAdministrationTools-Roles-AD-DS" state="true" />
<selection name="RemoteServerAdministrationTools-Roles-AD-DS-SnapIns" state="true" />
<selection name="RemoteServerAdministrationTools-Features-StorageManager" state="true" />
<selection name="RemoteServerAdministrationTools-Features-Wsrm" state="true" />
</package>
</servicing>
<cpi:offlineImage cpi:source="wim:d:/2008r2wim/install.wim#Windows Server 2008 R2 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
"@

View file

@ -0,0 +1,4 @@
"This is
a multi-line string
with indention
and such"

View file

@ -0,0 +1,19 @@
{{
: getDelimiter ( "-$ )
getToken keepString cr ;
: prepare ( -$ )
remapping off "" tempString ;
: readLine ( "-$ )
10 accept tib ;
: append? ( $$-$$f )
[ over ] dip compare [ 0 ] [ tib ^strings'append 10 ^strings'appendChar -1 ] if ;
---reveal---
: heredoc ( "-$ )
heap [ remapping [ getDelimiter prepare [ readLine append? ] while nip ] preserve ] preserve ;
}}
heredoc [END]
1 2 3
4 5 6
7 8 9
[END]

View file

@ -0,0 +1,11 @@
text$ ="
<<'FOO'
Now
is
the
time
for
all
good mem
to come to the aid of their country."
print text$

View file

@ -0,0 +1,13 @@
#!/usr/bin/txr -f
@(maybe)
@(bind USER "Unknown User")
@(or)
@(bind MB "???")
@(end)
@(output)
Dear @USER
Your are over your disk quota by @MB megabytes.
The Computer
@(end)

View file

@ -0,0 +1,8 @@
#!/bin/sh
cat << ANARBITRARYTOKEN
The river was deep but I swam it, Janet.
The future is ours so let's plan it, Janet.
So please don't tell me to can it, Janet.
I've one thing to say and that's ...
Dammit. Janet, I love you.
ANARBITRARYTOKEN

View file

@ -0,0 +1,6 @@
cat << EOF
Here documents do parameter and command substitution:
* Your HOME is $HOME
* 2 + 2 is `expr 2 + 2`
* Backslash quotes a literal \$, \` or \\
EOF

View file

@ -0,0 +1,5 @@
if true; then
cat <<- EOF
The <<- variant deletes any tabs from start of each line.
EOF
fi

View file

@ -0,0 +1,6 @@
cat << 'TOKEN'
If TOKEN has any quoted characters (like 'TOKEN', "TOKEN" or \TOKEN),
then all $ ` \ in the here document are literal characters.
$PATH \$PATH `shutdown now`
TOKEN

View file

@ -0,0 +1,9 @@
#!/bin/csh -f
cat << ANARBITRARYTOKEN
* Your HOME is $HOME
* 2 + 2 is `@ n = 2 + 2; echo \$n`
ANARBITRARYTOKEN
cat << 'ANARBITRARYTOKEN'
$PATH \$PATH `shutdown now`
'ANARBITRARYTOKEN'

View file

@ -0,0 +1,50 @@
hd =
-[
The text enclosed within the so called dash-brackets shown above
and below will be interpreted as a list of character strings. It
can contain anything except uninterpreted dash-brackets, and can
be used in any declaration or expression. The dash-brackets don't
have to be on a line by themselves.
]-
example =
-[Some additional facilities allow here-documents to be nested and
combined. Writing something like -[ hd ]- within a nested pair of
dash-brackets will cause the text declared above (having the
identifer hd) to be inserted at that point. The enclosed item can
be any expression that evaluates to a list of character strings.
We could therefore "escape" a literal dash-bracket within a
here-document by writing -[ <'-['> ]-. Dash-brackets can be nested
to any depth, alternating between literal text and compiled code
on each level.]-
template "x" =
-[A further use of this notation involves defining a text-valued
function. The output of this function will be this text, with
the argument inserted here -["x"]- and again here -["x"]-. The
argument type should be a list of character strings.]-
formletter ("x","y") =
-[Other calling conventions are possible. The left argument
comes out here -["x"]- and the right one here -["y"]-.]-
designpattern =
-[A point-free style of function declaration is also supported.
The argument comes out here -[. ~& ]-, after being fed through
the function appearing within the nested dash-brackets (in this
case the identity function). This usage is indicated by a period
after the left inner dash-bracket. Nesting is also allowed in
point free dash-bracket function specifications.]-
abstractionastronaut =
-[Higher order functions to any level are specified by piling on
the periods like this -[.. ~&]-. This one is a second order function
that needs to be applied to another function in order to get a
first order function such as the previous three examples.]-

View file

@ -0,0 +1,83 @@
'Purpose: Converts TXT files into VBS code with a function that returns a text string with the contents of the TXT file
' The TXT file can even be another VBS file.
'History:
' 1.0 8may2009 Initial release
'
'
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const TristateUseDefault = -2
set WshShell = CreateObject("WSCript.shell")
'File browse dialog box
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "All Files|*.*"
objDialog.InitialDir = WshShell.CurrentDirectory
intResult = objDialog.ShowOpen
If intResult = 0 Then
WshShell.Popup "No file selected.", 2, " ", 64
Wscript.Quit
Else
strFileNameIN = objDialog.FileName
End If
strFileNameOUT= strFileNameIN & "_CONVERTED.Vbs"
'Check if strFileNameOUT exists already
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFileNameOUT) then 'does the file EXIST?
' WScript.Echo "found"
OVRWT=MSGBOX(strFileNameOUT & " exists already"&vbCRLF&"Overwrite?",vbYesNoCancel,"Overwrite?")
if OVRWT = 6 then
'proceed
objFSO.DeleteFile(strFileNameOUT)
else
WshShell.Popup "Exiting as requested.", 1, " ", 64
Wscript.Quit
End If
Else
' WScript.Echo "not found" 'strFileNameOUT does NOT exists already
END if
strBaseName=objFSO.GetBaseName(strFileNameIN)
'open strFileNameANSI file, and put entire file into a variable ****SIZE LIMIT ??*****
Set objFile = objFSO.OpenTextFile(strFileNameIN, ForReading)
strText = objFile.ReadAll
objFile.Close
'Start converting
'Convert " to ""
strOldText = Chr(34)
strNewText = Chr(34)&Chr(34)
strText = Replace(strText, strOldText, strNewText)
'Add objTXTFile.writeline ("
strOldText = VBCRLF
strNewText = """) &vbCrLf"&VBCRLF&" strText=strText& ("""
strText = Replace(strText, strOldText, strNewText)
'Converting done
strFileName=objFSO.GetFileName(strFileNameIN)
'Write to file
Set objFile = objFSO.OpenTextFile(strFileNameOUT, ForAppending, True)
objFile.WriteLine "'this Function will return a string containing the contents of the file called "&strFileName
objFile.WriteLine "msgbox "&strBaseName &"()"
objFile.WriteLine vbCrLf
objFile.WriteLine "Function "&strBaseName&"()"
objFile.WriteLine " 'returns a string containing the contents of the file called "&strFileName
objFile.WriteLine " Dim strText"
objFile.WriteLine " strText= ("""&strText&""") &vbCrLf"
objFile.WriteLine " "&strBaseName&"=strText"
objFile.WriteLine "End Function"
objFile.Close
WshShell.Popup "created " & strFileNameOUT, 3, "Completed", 64

View file

@ -0,0 +1,4 @@
code Text=12;
Text(0, " ^"Heredocs^" are pretty much automatic. Multiple lines and
whitespace, such as indentations, are output exactly as written. Quote
marks (^") and any carets (^^) within the string must be escaped.")