Here's the code:

let square x = x * x

let list1 = [1 .. 10]

let rec sum list =

match list with

| h::tail -> (sum tail) + h

| []->0

let rec sumSquaredListElements list =

match list with

| h::tail -> (sumSquaredListElements tail) + h * h

| [] -> 0

printfn "%A" list1

let print x = printfn "%i" x

let x1 = square (sum list1)

let main () = print x1

main()

Random programming things I'd want to remember

## Wednesday, November 12, 2008

## Tuesday, November 11, 2008

### Learning a functional language

A challenge in learning a language is application of the newly-acquired knowledge. A wonderful web site, "Project Euler," presents a number of mathematical puzzles. I could learn F# by solving those problems. Here's the answer to problem number 1:

#light

open System

let by32 = List.filter(fun n -> n%3 = 0 || n%5 = 0) [1 .. 9]

let rec sum list =

match list with

| h::tail -> (sum tail) + h

| []->0

printfn "%A" by32

let print x = printfn "%i" x

let x1 = sum by32

let main () = print x1

main()

Console.ReadKey(true)

#light

open System

let by32 = List.filter(fun n -> n%3 = 0 || n%5 = 0) [1 .. 9]

let rec sum list =

match list with

| h::tail -> (sum tail) + h

| []->0

printfn "%A" by32

let print x = printfn "%i" x

let x1 = sum by32

let main () = print x1

main()

Console.ReadKey(true)

Subscribe to:
Posts (Atom)

## Labels

angularjs
(2)
aspnet
(2)
BackgroundWorker
(2)
benchmarking
(1)
binaryreader
(1)
bootable
(1)
c#
(40)
canvas
(1)
checkbox
(1)
code snippet
(1)
config
(1)
controls
(1)
data manipulation
(2)
debugging
(1)
embeddedresource
(3)
entity-framework
(2)
Excel
(1)
f#
(2)
firefox
(1)
foreign language
(1)
git
(2)
hardware
(1)
html
(1)
iso
(1)
ItemLoader
(1)
ItemTester
(1)
japanese
(1)
javascript
(3)
ms-access
(2)
multithreading
(3)
mvc
(1)
mvvm
(7)
objective-c
(10)
office
(1)
powershell
(1)
productivity
(1)
programming
(52)
project_euler
(2)
radiobutton
(1)
reflection
(3)
resolution
(1)
shortcut
(1)
silverlight
(3)
source control
(1)
sql
(2)
system administration
(2)
system rescue cd
(1)
tdd
(4)
tip
(2)
UI
(1)
usb
(1)
visualstudio
(6)
visualstudio2008
(1)
webapi
(1)
webdev
(1)
windows
(1)
windows-phone
(4)
windows-phone-7
(8)
winforms
(4)
wpf
(4)
xaml
(8)