Tuesday, March 4, 2008

Learning F# - List Concatenation

My first attempt with lists in F# :-)

let lofl = [[1;2];[3;4];[5;6]]

let rec concat ll =
match ll with
| [] -> []
| h :: t -> h @ concat t

printf "%A" (concat lofl)
read_line()

Sunday, March 2, 2008

Embed Win32 resources in C# programs

This article explains all ...
http://www.codeproject.com/KB/cs/embedwin32resources.aspx

ADO - Python

Querying ACCESS with Python


from win32com.client import Dispatch as CreateObject

conn = CreateObject("ADODB.Connection")
mdb = r"C:\northwind.mdb"
conn.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=%s;"%mdb)


def execRequest(sql):
r,t = conn.Execute(sql )
cust = "<table>\n"
while not r.EOF:
s = "<tr>"
for item in r.Fields:
if item.Name == "ContactName" or item.Name == "Address":
s+= "<td>%s</td>"%(item.Value)
s += "</tr>\n"
cust += s
r.MoveNext()
cust += "</table>\n"
return cust

cust = execRequest("select * from customers")

conn.Close()