2
votes
Vote UpVote

Weird code snippet #1: Pseudobinary case statement

Lars Fosdal – Curt Carpenter suggested a language addition for handing binary case logic.That gave me this idea. Chalk it up as another weird code snippet from yours truly.///<summary>> Convert array of booleans to a pseudobinary integer. ///Good for up to 12 bits.</summary>function BoolToInt(B: Array of Boolean):Integer;var x : Boolean;begin Result := 0; for x in B do begin Result := Result * 10; if x then Inc(Result); end;end;procedure SexistTestLogic(const Cute, Funny, Smart: boolean);begin case BoolToInt([Cute, Funny, Smart]) of 000: Avoid; 001: Admire; 010, 011: ...
Favorite? Off-Topic? Lars Fosdal @ 2011-07-09 00:04

Statistics

Visits: 831
Votes: 2
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Alister Christie
jamiei
Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)