Bottles Of Beer (VB11 Stylee)
Just been messing around with VB11 and did an implements of the Bottles Of Beer Song
It utilises the following features of the language.
I had to configure the IDE feature of pretty printing vb.net, to make the text align properly.
This is because the auto-indentation of the XML introduced unwanted significant white-space.
Just been messing around with VB11 and did an implements of the Bottles Of Beer Song
Imports System.Runtime.CompilerServices
Module BottleSong
Sub Main()
Console.WriteLine(<Song>
<%= Iterator Function()
For i=99 to 0 Step -1:Yield i:Next
End Function().Select(Function(Bottles)<Verse>
<%= Bottles.OfBeer %> on the wall, <%= Bottles.OfBeer %>.
<%= If(Bottles > 0, "Take one down and pass it around", "Go to the store and buy some more") %>.
<%= (Bottles - 1).OfBeer %> on the wall,<%= (Bottles - 1).OfBeer %>.
</Verse>)%></Song>.Value)
End Sub
<Extension()>Public Function OfBeer(Bottles As Integer) As XNode
Bottles = If(Bottles < 0, 99, Bottles)
Return <Bottles><%= Bottles %> bottle<%= If(Bottles <> 1, "s", "") %> of Beer</Bottles>
End Function
End Module
It utilises the following features of the language.
- XML Literals
- Extension Method
- LINQ
- Iterator Lambda (VB11)
I had to configure the IDE feature of pretty printing vb.net, to make the text align properly.
This is because the auto-indentation of the XML introduced unwanted significant white-space.
2 Comments On This Entry
Page 1 of 1
Page 1 of 1
|
|



2 Comments









|