Michells Mesterværk

Vinderen af låge 7.

by Administrator 9. December 2009 11:29

Så fik jeg endelig noget VB kode ind i konkurrencen. Lækkert!

Lågens vinder har flottet sig og bygget et fedt library af extension methods til bla. generiske collections. Jeg synes der var andre der havde lavet noget næsten ligeså lækkert, men VB er efterhånden et sjældent syn og derfor synes jeg, jeg vil lade denne låge gå til Klaus Even Enevoldsen. TIllykke med dit nye Star Wars flagskib :)

Forøvrigt har Klaus en ganske fed blog på http://even.dk/

Module Module1
Sub Main()
' BigInteger sample
Dim A = New SortedSet(Of System.Numerics.BigInteger)()
A.Add(System.Numerics.BigInteger.One)
A.Add(System.Numerics.BigInteger.Zero)
A.Add(System.Numerics.BigInteger.MinusOne)
A.Add(CType(Int64.MaxValue, System.Numerics.BigInteger) + 1)
A.Add(CType(Int64.MinValue, System.Numerics.BigInteger) - 1)
Console.WriteLine(A.ToXmlString())

' Silly Parallel sample
Dim List = New List(Of System.Numerics.BigInteger)()
For i = 0 To 10
List.Add(i * 10)
Next

Console.WriteLine(List.AddOne().ToDelimitedString())

' My hopes
Console.WriteLine(String.Format("Will I Win The LEGO Clone Wars box? {0}", Boolean.TrueString.WillIWin()))

Console.ReadKey()
End Sub
End Module

Module ExtensionMethods
<System.Runtime.CompilerServices.Extension()>
Public Function ToXElement(Of T)(ByVal sortedSet As SortedSet(Of T)) As System.Xml.Linq.XElement
Dim Result = <SortedSet created=<%= Now().ToUniversalTime().ToString() %> datatype=<%= GetType(T).ToString() %>>
</SortedSet>

For Each Element In sortedSet
Result.Add(<Element><%= Element.ToString() %></Element>)
Next

Return Result
End Function

<System.Runtime.CompilerServices.Extension()>
Public Function ToXmlString(Of T)(ByVal sortedSet As SortedSet(Of T)) As String
Return sortedSet.ToXElement().ToString()
End Function

<System.Runtime.CompilerServices.Extension()>
Public Function WillIWin(Of T)(ByVal anything As T) As String
Return "Yes!"
End Function

<System.Runtime.CompilerServices.Extension()>
Public Function AddOne(ByVal list As List(Of System.Numerics.BigInteger)) As List(Of System.Numerics.BigInteger)
Dim Result = New List(Of System.Numerics.BigInteger)()

For Each item In list.AsParallel()
Result.Add(item.AddOne())
Next

Return Result
End Function

<System.Runtime.CompilerServices.Extension()>
Public Function AddOne(ByVal value As System.Numerics.BigInteger) As System.Numerics.BigInteger
Return value + 1
End Function

<System.Runtime.CompilerServices.Extension()>
Public Function ToDelimitedString(ByVal list As List(Of System.Numerics.BigInteger)) As String
Dim BobTheStringBuilder = New System.Text.StringBuilder()

For Each item In list
If BobTheStringBuilder.Length > 0 Then
BobTheStringBuilder.AppendFormat(", {0}", item.ToString())
Else
BobTheStringBuilder.Append(item.ToString())
End If
Next

Return BobTheStringBuilder.ToString()
End Function
End Module


Tags:

Comments

12/9/2009 12:16:17 PM #

Klaus Even Enevoldsen

Jamen, det var da en dejlig nyhed! Tusind tak for det, min ældste søn bliver meget glad, når jeg fortæller ham at jeg har vundet. Smile

Klaus Even Enevoldsen Denmark

1/21/2010 9:33:27 AM #

same day payday loans

Lucrative post designe! Thanks

same day payday loans United States

2/14/2010 1:42:34 PM #

اخبار

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

اخبار Egypt

2/24/2010 7:50:43 PM #

skate 3 Release

<A href="http://skate3.de/release/">Skate 3 Release</A>

skate 3 Release Germany

2/28/2010 3:18:19 AM #

penny stocks

Great blog it's not often that I comment but I felt you deserve it.

penny stocks United States

2/28/2010 11:32:50 AM #

money

Great blog it's not often that I comment but I felt you deserve it.

money United States

3/4/2010 6:22:33 AM #

watch movies online free

I like streaming movies online, it is way cheaper than going to the theaters.

watch movies online free United States

3/4/2010 8:13:32 AM #

watch movies online free

I love streaming movies online, it is way cheaper than going to the theaters.

watch movies online free United States

3/9/2010 8:43:51 PM #

WoW Mobile

Do you know which cell phone companies allow tethering?

WoW Mobile United States

3/10/2010 12:01:28 AM #

WoW Mobile

Do you know which mobile phone companies allow tethering?

WoW Mobile United States

3/17/2010 2:05:53 AM #

ssk sorgulama

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

ssk sorgulama United States

3/17/2010 11:47:26 AM #

arac sorgulama

I admire the valuable information you offer in your articles. I will bookmark your blog and have my children check up here often. I am quite sure they will learn lots of new stuff here than anybody else!

arac sorgulama United States

3/20/2010 3:27:01 PM #

ehliyet

Excellent post.I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work.

ehliyet Denmark

7/20/2010 8:55:37 AM #

Vietnam Visa

The blog was absolutely fantastic! Brilliant post, Lot of information and inspiration, keep up the good work.

Vietnam Visa United States

Add comment


(Will show your Gravatar icon)

(De 3 specielle karaktere i det danske alfabet?)
  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen