You are viewing [info]mhnicholson's journal

Haskell Notes for old farts

Sep. 17th, 2011 | 10:10 am

Name reminds me of Leave It to Beaver

not-equals is /= instead of !=

LHFGG says ++ implementation has O(|left|) concatenation instead of O(1).
Look for a streams implementation. (see "comprehension" below)
colon is the cons operator
list.get(x) is !! x

car/cdr is head/tail
last/butlast is last/init

cddddr is drop 4 (where 4 is the count of d's) so tail is drop 1

max and min are spelled out
[x..y] specifies a range with step +1
[x,x2..y] specifies a range with step (x2-x1)
.. works for floats

map-filter combo is call a "comprehension"
[expression | x<-[range], constraint]
func x y can be syntactic sugared as x `func` y

let makes variables (scope?)

The following works, so cons-stream is lazy as it should be
let nats = [1,2..]
let evens = [2*x | x<-nats]
let bomb = nats ++ evens
take 4 bomb


Multiple ranges does a walk of all combinations with first list incrementing most slowly and so on.

underscore is used both as a void type and /dev/null for values

If an = without a let a function declaration?
let expr = value
myFunc arg = value

Link | | Add to Memories | Share

Functional Java Examples

Sep. 17th, 2011 | 08:24 am

I'm looking at the examples on this page and so far everything looks like scheme with the verbs moved around.

The option bind example tweaked me as being really bad code. The expression

new F<Integer, Option<Integer>>() {  
    public Option<Integer> f(final Integer i) {  
        if(i % 2 == 0) return some(i * 3); else return none();  
    }
}


is repeated thrice. Why not save the expression in a variable?

F<Integer, Option<Integer>>() trippleOdd = new F<Integer, Option<Integer>>() 
{  
    public Option<Integer> f(final Integer i) 
    {  
        if(i % 2 == 0) return some(i * 3); 
        else return none();  
    }
};


As far as I can tell the scope bindings would all be identical and the result is unchanged. Switching from learning mode to judgmental mode: This is Bad Code(tm) unless someone can tell me why it isn't.

Link | | Add to Memories | Share

Nascent Tiller sequel aborted

May. 27th, 2011 | 06:47 am

The obvious part of this post this post is that an anti-abortion zealot was preparing to murder a medical professional, that he had a gun to do so, and that the only reason he got caught before making the attempt was some premature firing in his hotel. The DA will have to prove intent to get him on the charges of attempted murder and intimidation, but the concealed weapon charge and illegal discharge of a firearm are trivial to enforce.

This blog is about the reaction of the Wisconsin state senate: they are changing the law to remove the easy-to-prove charges. Those voting with the majority have now officially taken a pro-murder stance (as long as the intended victim is "one of them"). I have no doubt that if the next stray bullet from a concealed weapon kills a child who just happened to stay at the wrong hotel, they will be quick to point out that this is a tragedy and that we shouldn't assign blame. But they are wrong. This is the mistake that will lead to that tragedy. This is what they deserve to be blamed for.

In Wisconsin that vote only took three people to pass, which underscores the dangers of allowing demagogues into power when power is so concentrated. Politics is life-or-death serious.

Link | | Add to Memories | Share

Second Amedment Remedies

Jan. 8th, 2011 | 01:10 pm

If you can't beat your opponent in an election, have them shot in the head.

Link | | Add to Memories | Share

Why isn't this bigger news?

Dec. 14th, 2010 | 08:15 pm

Someone claims to have the basis for an HIV cure. It seems this would be bigger news if true. Who's heard more?

Link | | Add to Memories | Share

Moving to DW

Sep. 1st, 2010 | 12:25 pm

I've had the account "melanoman" at DW for a while now, but didn't want to move my journal because 90% of my reading list was LJ-based. The twitter integration finally annoyed me enough to move, especially now that my reading list is more like 50/50 between the sites.

Effective immediately, consider this journal closed. I can't risk someone accidentally exposing something private related to the hurricane through a cross-posted comment.

Comments have been disabled, but you can still view everything according to the original permissions at melanoman.dreamwidth...

Link | | Add to Memories | Share

Don't Be A Sucker

Sep. 1st, 2010 | 06:20 am

Some sage advice from 1947 from people who had lived the consequences of the alternative.



"Here in America it is not a question of whether we tolerate minorities. America IS minorities."

Remember.

Link | | Add to Memories | Share

Dreamwidth codes

Aug. 20th, 2010 | 07:19 am

I have a bunch. E-mail me if you want one.

Link | | Add to Memories | Share

Sovereign Nations

Jul. 16th, 2010 | 05:38 am

In case you haven't heard, the Iroquois National Lacrosse team is being denied travel rights to England by the UK ministries. The team is ranked 4th in the world, and is a huge source of pride from the nation where the game was invented. The coverage I'm hearing on NPR keeps referring to the "special passports" the team members hold. I can't stand that term. When they say "special" they don't mean that the thing is made of some special material. The "special" part is that a tribal government is issuing them.

The travel problems started in La Guardia (a New York, USA airport) where the officials there had trouble validating the passports. The consultations went all the to Secretary of State Hillary Clinton, who NPR reported gave "special" permission for the Iroquois to use their passports. The UK ministries did not allow the passports in Heathrow, so the team was turned back and missed their first match. The host team England won that match by denying its rival admission to the match.

The Haudenosaunee Nation (which includes the Iroquois, Mohawk, and other tribes) has been issuing these passports since the 1970s and continues to upgrade to the evolving anti-fraud standards. Other hosts have honored the passports, which is how the team managed it's 4th-place world ranking. In practice, the big difference between the Iroquois passports and those of the US and Canada is inclusion in an anti-fraud database controlled by the United Nations. The Nation has expended over US$1.5 million to upgrade to the latest anti-fraud technologies, so at this point the difference is in international recognition, not the physical documents. England was party to a treaty with the Nation in the 18th century that allowed them travel rights, but isn't living up to that agreement now, even though Canadian transport on many Haudenosaunee roads is still permitted because of that treaty.

I'd like to see the governing body for lacrosse refuse to recognize the UK as a potential host until the UK recognizes the travel rights of the league's most senior member.

Link | | Add to Memories | Share

He who control the present controls the past

Jul. 3rd, 2010 | 03:51 am

The key phrase is around 0:27-0:29. Mr. Steel (The Republican National Committee Chair) calls Afghanistan a "War of Obama's choosing ... not something the U.S. ... wanted to engage in."

Link | | Add to Memories | Share