A Quarter Century

No one is really quite sure the day I — Pookie the Cockatiel — was hatched. So, after careful investigation, it was determined that Columbus Day October 12 was probably my hatch date. Today, I am 25 years old, not bad.

Let me just say it is difficult work to train humans to communicate with us. Primarily for survival reasons, we birds do not reveal a lot. But, Dad and Mrs. H. have gotten reasonable marks for figuring me out.

Doing what I always do, inspecting.

Dad left his dresser messy just for my birthday.

Advertisements

2 Comments

Filed under Bird Stories, General

Buzzards Inc.

It finally happened. With the exception of local stores, like your favorite restaurant, fabric, hardware,  or your mechanic, all large companies are beginning to blur in my mind. I cannot seem to tell them apart.

Whether it is a company that produces products for the utility sector, home and automobile insurance, or specialized software for government, to me, they might as well just be one large company. Their behavior seems to be merging into a set of common behaviors.

Here are some of the telltale signs this is happening.

  1. It is almost impossible to reach someone on the phone. Most companies have had phone menus for many years, but now, these menus seem protected with nearly impenetrable armor. You’ll be prompted with questions to get you past a checkpoint. Some of these questions could easily be used on Jeopardy.
  2. To solve a problem, like you want some information sent by mail, you are presented with impossibilities that would give master players of the original Adventure game fits. You are told that this other department cannot send you that information, because they cannot see it.
  3. Support personnel are reading from a script: “Well, you need to adjust the spark advance and fuel mixture.” Your car does not have settings for spark and fuel, but a 1926 Rolls Royce might.

So, I am thinking it might just be easier to have one company with a suitable name. The Three Stooges had the right idea, with Panther Brewing Company, A Panther President.

Leave a comment

Filed under rants

So an F# Sequence Should Stick Around For a While

If you create a sequence in Clojure, the sequence sticks around within the scope of its creation. That is, once a Clojure sequence is created and bound to a var, nothing special has to be done to make sure its contents stick around. This is not so with F#.

Take this program


open System
open System.Collections.Generic
open System.Text
open System.IO
#nowarn "40"

let rec readLines () =
    seq {
    let line = Console.ReadLine()
    if not (line.Equals("")) then
           yield Int32.Parse(line)
           yield! readLines ()
    }

[<EntryPoint>]
let main argv =
    let inSeq = readLines ()    

    inSeq

    |> Seq.length

    |> printfn "%d lines read"

    // This will keep it alive enough to read your output
    Console.ReadKey() |> ignore
    0

Because of a sequences’ inherent laziness, the reading in of numbers does not begin until inSeq’s length is computed. Without caching inSeq, you will have to read the integers in again if you want to iterate the sequence, unless this change is made


let inSeq = readLines () |> Seq.cache

Leave a comment

Filed under Clojure, F#

Generating F# Sequences From Console Input

I got a very nice answer on SO to why a function was not executing.


open System
open System.Collections.Generic
open System.Text
open System.IO
#nowarn "40"

let rec readlines () =
     seq {
           let line = Console.ReadLine()
           if not (line.Equals("")) then
              yield line
              yield! readlines ()
}

[<EntryPoint>]
let main argv =
      let inSeq = readlines ()

      inSeq
      |> Seq.length
      |> printfn "%d lines read"

      // This will keep it alive enough to read your output
      Console.ReadKey() |> ignore
      0

Leave a comment

Filed under F#

The Sugar Coated Documentary

In May of this year, I came across an interesting documentary on Netflix. Then I recently heard about one of the people mentioned in the documentary, a dentist in San Fransisco in an NPR news story.

Even if you disagree with the documentary, at least it might make you think. Oh, and I did enjoy birthday cake several times this Summer. I am not a monk.

Leave a comment

Filed under Health

Nice F# List.fold example

Got this example from here.


open System
open System.Threading
open System.Collections.Generic
open System.Linq
open System.Text
open System.Threading.Tasks
open System.IO
open Microsoft.VisualBasic.FileIO


let main argv =
   let data = [(Cats,4);
               (Dogs,5);
               (Mice,3);
               (Elephants,2)]

   let count = List.fold (fun acc (nm,x) acc+x) 0 data
   printfn "Total number of animals: %d" count


Even though I’ve used map and other functions in Clojure, I’ve forgotten the basics of an inline function. The value of 0 is assigned to nm, and x takes on the first row of data.

 

Leave a comment

Filed under F#

Reading in a .csv file

Yes, it is my favorite subject, which is transforming data in .csv files. Here’s reading data into a variable in F#.


open System
open System.Threading
open System.Collections.Generic
open System.Linq
open System.Text
open System.Threading.Tasks
open System.IO
open Microsoft.VisualBasic.FileIO

[<EntryPoint>]
let main argv =
  let csv_fileH = new TextFieldParser(test1.csv)
  csv_fileH.TextFieldType = FieldType.Delimited |> ignore
  let x = csv_fileH.SetDelimiters(',')
  let csv_data = new List string[]()

  let eod = csv_fileH.EndOfData

  if not eod then
    let column_headings = csv_fileH.ReadFields()
    csv_data.Add(column_headings) |> ignore

    // Parentheses are needed after function definition to produce type bool.
    let read_rest_of_csv() =
    csv_data.Add(csv_fileH.ReadFields()) |>
    not csv_fileH.EndOfData

    while read_rest_of_csv() do ignore None

  0 // return an integer exit code

This program is associated on stackoverflow with some very good answers to a question I asked.

Leave a comment

Filed under F#

A First [and Simple] F# Sample

Anything worth learning should not be simple. Learning Clojure was not simple, and hacking with C# for the first time was not simple either, so I should not expect simple while learning F#.

Here is a first small program, because I have found a dirth of regular simple examples out on the web, especially those calling .Net functions.


 open System
 open System.Threading
 open System.Collections.Generic
 open System.Linq
 open System.Text
 open System.Threading.Tasks
 open System.IO
 open Microsoft.VisualBasic.FileIO

[EntryPoint]
let main argv =
    let parser = new TextFieldParser(&quot;test1.csv&quot;)
    parser.TextFieldType = FieldType.Delimited |&amp;amp;amp;gt; ignore
    let x = parser.SetDelimiters(&quot;,&quot;)

    let eod = parser.EndOfData
    if not eod then
        let column_headings = parser.ReadFields()
        printf &quot;%A&quot; column_headings |&amp;amp;amp;gt; ignore
0 // return an integer exit code

This is the contents of test1.csv

&lt;br data-mce-bogus=&quot;1&quot;&gt;

AGY/DIV,STS,GIC-ID,LAST-NAME,FIRST-NAME,COVERAGE DESCRIPTION,PREMIUM,RUN-DATE,BILL MONTH&lt;br data-mce-bogus=&quot;1&quot;&gt;

 

Leave a comment

Filed under F#

Good F# Example

After a decade of Linux database work, a lot more of my time is being spent on the Microsoft platform, using Visual Studio. Because our enterprise is on Windows 7, Visual Studio 2012 is as high as I can use.

Over the past six years, I’ve learned enough Clojure to write small applets; added to my Perl knowledge; and ported a VB application to C#.

So, I am learning F# now, and was looking for a good example. I was lucky to find one that includes posting a dialog box. I had to tweak a couple of things, because this example was written for Visual Studio 2010, but it is the first good example I have found for F#.

Leave a comment

Filed under .Net Languages

Does anyone remember Major Mudd (Greater Boston)?

Long before the Boston Red Sox reversed the curse, when I was in the 4th grade, I met my first television personality, Major Mudd https://www.youtube.com/watch?v=fT7bkXXvDLM . It was down at the South Shore Plaza in Braintree, MA. He had a weekday morning cartoon show, including a serialized non-cartoon about two brothers traveling down a river and going back in time.

We remember you well, Major Mudd.

Leave a comment

Filed under Annecdotes, Persons of Note