add fsharp version

This commit is contained in:
unknown committed 2015-10-26 13:38:45 +01:00
1 parent 8862a771a5
commit cb45ff3fe7
7 files changed
+308

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
+63
View File
@@ -0,0 +1,63 @@
module GildedRose
open System.Collections.Generic
type Item = { Name: string; SellIn: int; Quality: int }
type GildedRose(items:IList<Item>) as this =
let Items = items
member this.UpdateQuality() =
for i = 0 to Items.Count - 1 do
if Items.[i].Name <> "Aged Brie" && Items.[i].Name <> "Backstage passes to a TAFKAL80ETC concert" then
if Items.[i].Quality > 0 then
if Items.[i].Name <> "Sulfuras, Hand of Ragnaros" then
Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality - 1) }
else
if Items.[i].Quality < 50 then
Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality + 1) }
if Items.[i].Name = "Backstage passes to a TAFKAL80ETC concert" then
if Items.[i].SellIn < 11 then
if Items.[i].Quality < 50 then
Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality + 1) }
if Items.[i].SellIn < 6 then
if Items.[i].Quality < 50 then
Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality + 1) }
if Items.[i].Name <> "Sulfuras, Hand of Ragnaros" then
Items.[i] <- { Items.[i] with SellIn = (Items.[i].SellIn - 1) }
if Items.[i].SellIn < 0 then
if Items.[i].Name <> "Aged Brie" then
if Items.[i].Name <> "Backstage passes to a TAFKAL80ETC concert" then
if Items.[i].Quality > 0 then
if Items.[i].Name <> "Sulfuras, Hand of Ragnaros" then
Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality - 1) }
else
Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality - Items.[i].Quality) }
else
if Items.[i].Quality < 50 then
Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality + 1) }
()
[<EntryPoint>]
let main argv =
printfn "OMGHAI!"
let Items = new List<Item>()
Items.Add({Name = "+5 Dexterity Vest"; SellIn = 10; Quality = 20})
Items.Add({Name = "Aged Brie"; SellIn = 2; Quality = 0})
Items.Add({Name = "Elixir of the Mongoose"; SellIn = 5; Quality = 7})
Items.Add({Name = "Sulfuras, Hand of Ragnaros"; SellIn = 0; Quality = 80})
Items.Add({Name = "Sulfuras, Hand of Ragnaros"; SellIn = -1; Quality = 80})
Items.Add({Name = "Backstage passes to a TAFKAL80ETC concert"; SellIn = 15; Quality = 20})
Items.Add({Name = "Backstage passes to a TAFKAL80ETC concert"; SellIn = 10; Quality = 49})
Items.Add({Name = "Backstage passes to a TAFKAL80ETC concert"; SellIn = 5; Quality = 49})
Items.Add({Name = "Conjured Mana Cake"; SellIn = 3; Quality = 6})
let app = new GildedRose(Items)
for i = 0 to 30 do
printfn "-------- day %d --------" i
printfn "name, sellIn, quality"
for j = 0 to Items.Count - 1 do
printfn "%s, %d, %d" Items.[j].Name Items.[j].SellIn Items.[j].Quality
printfn ""
app.UpdateQuality()
0
+76
View File
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>2660ef56-b4c1-4dcf-b106-278211bd26c6</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>GildedRose</RootNamespace>
<AssemblyName>GildedRose</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion>
<Name>GildedRose</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Debug\GildedRose.XML</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Release\GildedRose.XML</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Compile Include="GildedRose.fs" />
</ItemGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>