我一直在Win8.1上使用VS2015在F#中开发但我最近买了一台iMAC并为MacOS X elCapitan 10.11.3安装了Xamarin Studio 6.0
有些代码在VS2015上正常编译,我正在尝试在iMAC上编译它。
Array.tail在F#interactive中工作但是 我有一个Array.tail
的编译错误Projects / MyAlgos / MyAlgos / Program.fs(25,25):错误FS0039:未定义值,构造函数,命名空间或类型'tail'(FS0039)(MyAlgos)
在Xamarin的Solution explorer面板中,我已将Target Framework设置为.NET Framework 4.5.2,(就像它在VS2015中设置一样)
//////// Travelling Salesman problem ////////
open System
open System.Collections
open System.Collections.Generic
open System.IO
open System.Windows
open FSharp.Charting
//open MyLibrary
//open MyLibrary.MyUsefulFunctions
//open MyLibrary.MyCollections
exception InnerError of string
let stopWatch = System.Diagnostics.Stopwatch.StartNew()
///////////////// preparing the data /////////////////
// format of the files
//[number_of_cities]
//[x_1] [y_1] // coordinate
let x = File.ReadAllLines "C:\Users\Fagui\Documents\GitHub\Learning Fsharp\Algos\Algos\Stanford Algo II\Algo II - PA5 - TSP.txt"
let split (text:string)=
text.Split [|'\t';' '|]
let splitInto2Values (A: string []) =
(float A.[0],float A.[1])
let parseLine (line:string) =
line
|> split
|> splitInto2Values
let num_cities = int x.[0]
let cities = x |> Array.tail |> Array.map parseLine // [x_1][y_1]
我也有这个相关的警告
/Library/Frameworks/Mono.framework/Versions/4.4.0/lib/mono/4.5/Microsoft.Common.targets:警告:此工具集不支持TargetFrameworkVersion'v4.5.2'(ToolsVersion:4.0)。 (MyAlgos)
答案 0 :(得分:2)
让cities = x |> Array.tail |> Array.map parseLine
错误FS0039:值,构造函数,命名空间或类型' tail'未定义(FS0039)(MyAlgos)
我没有在编译代码(或交互式)中找不到Array.tail
的任何问题。
您是否尝试过创建F#控制台项目并进行简单的Array.tail
测试?请参阅下面的示例来源。
[<EntryPoint>]
let main argv =
let array3 = [| 1; 2; 3 |]
let array2 = array3 |> Array.tail
let array1 = array2 |> Array.tail
printfn "%A\n%A\n%A" array3 array2 array1
0 // return an integer exit code
[|1; 2; 3|]
[|2; 3|]
[|3|]
Press any key to continue...
>fsharpc
F# Compiler for F# 4.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
>mono --version
Mono JIT compiler version 4.2.3
要删除框架警告,您可以将项目设置为&#34; Mono / Net 4.5&#34;