Tuesday, March 16, 2010

A Brief Introduction to Fluent English

I've been toying around a while with the idea to modify the English language to fix some inconsistencies. I thought I'd briefly lay out some of the goals of what I call "Fluent English."

1. The overall purpose of Fluent English is to resolve the numerous inconsistencies in grammar of the current English language.

2. The purpose is NOT to influence any cultural or personal preferences on the language. In other words, I am not trying to force any particular "style" of writing on the language--merely grammatical changes.

3. I am striving to not change the vocabulary--most of the base forms of words should remain intact(with the exception of homonyms and homophones).

4. An additional "inconsistency" dictionary is to be completed after the grammatical rules of Fluent English are created. This involves listing the English form of inconsistent words and their corresponding corrected value in Fluent English.

I will try to post my ideas here about the language as I begin to structure it. I welcome any suggestions.

Monday, March 15, 2010

Yielding Lists in F#

I've been watching a great video tutorial on F# ().

One of the things that really interested me was how how easy it is to compose lists. Take the function below that can generate a list of files from a directory and any subsequent subdirectories:

open System.IO

let rec allFiles dir =
[for file in System.IO.Directory.GetFiles dir do
yield file

for subDir in System.IO.Directory.GetDirectories dir do
yield! allFiles subDir]

I'm essentially looping through every file and yielding it into the list. F# intrinsically knows to throw the data into a list because of the brackets. I don't have to worry about creating "objects" to store the data--I treat the data as a function. Also notice the "yield!" statement. The exclamation point tells F# that you want to yield the results of another list into the list. In this case, because I marked the function as recursive("rec"), I can simply recursively call each branch of the file directories until I reach the leaf node.

Here is what this function would look like in C#:

public static List getAllFiles(string dir)
var allFiles = new List();

foreach(var file in Directory.GetFiles(dir))

foreach (var subDir in Directory.GetDirectories(dir))
getAllFiles(subDir).ForEach(file => allFiles.Add(file));

return allFiles;

As you can see, F# is much more compact and fluent in expressing functions.