f#

fsi.exe Assembly: Anyone know how to embed it?

北城余情 提交于 2020-02-03 05:14:05
问题 Long time reader, very first question. fsi.exe is a .NET executable and therefore contains its own assembly complete with all the yummy methods and whatnot fsi uses to execute F# scripts. Looking at the assembly in .NET Reflector (pick your class, but Shell is the best example) reveals a bunch of garbage* names that look like decorated C++ functions (say, from Dependency Walker). Incidentally and slightly beside the point, F# assemblies compile in much the same way, with lots of garbage*

Is possible to parse “off-side” (indentation-based) languages with fparsec?

别说谁变了你拦得住时间么 提交于 2020-02-03 04:58:26
问题 I wish to use FParsec for a python-like language, indentation-based. I understand that this must be done in the lexing phase, but FParsec don't have a lexing phase. Is possible to use FParsec, or, how can feed it after lexing? P.D: I'm new at F#, but experienced in other languages 回答1: Yes, it's possible. Here is a relevant article by FParsec author. If you want to go deeper on the subject, this paper might worth a read. The paper points out that there are multiple packages for indentation

Is possible to parse “off-side” (indentation-based) languages with fparsec?

怎甘沉沦 提交于 2020-02-03 04:58:16
问题 I wish to use FParsec for a python-like language, indentation-based. I understand that this must be done in the lexing phase, but FParsec don't have a lexing phase. Is possible to use FParsec, or, how can feed it after lexing? P.D: I'm new at F#, but experienced in other languages 回答1: Yes, it's possible. Here is a relevant article by FParsec author. If you want to go deeper on the subject, this paper might worth a read. The paper points out that there are multiple packages for indentation

How does Silverlight determine an assembly is “Silverlight”?

那年仲夏 提交于 2020-01-31 07:22:31
问题 I'm trying to compile code from F# to use in Silverlight. I compile with: --noframework --cliroot "C:\program Files\Microsoft Silverlight\2.0.31005.0" --standalone This generates a standalone assembly that references the SL framework. But when I try to add a reference to the generated assembly, I get this error: You can only add project references to other Silverlight projects in the solution. What is the VS plugin doing to determine that this isn't a Silverlight assembly? Here's the manifest

Any R-Tree implementation in F# (or C#)? [duplicate]

不羁的心 提交于 2020-01-31 05:15:05
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Is there any documented free R-Tree implementation for .NET? Are there any R-Tree implementations in F#? Assumptions are: no need for insertion or deletion, fixed set of Geo-Fences (regions). Needs are: very fast search time. Thank you 回答1: Here's a quick translation of this one in OCaml to F#. namespace RTree open System module Envelope = type t = float * float * float * float let ranges_intersect a b a' b' = a

Is there an equivalent to creating a C# implicit operator in F#?

北城以北 提交于 2020-01-28 19:46:24
问题 In C# I can add implicit operators to a class as follows: public class MyClass { private int data; public static implicit operator MyClass(int i) { return new MyClass { data = i }; } public static implicit operator MyClass(string s) { int result; if (int.TryParse(s, out result)) { return new MyClass { data = result }; } else { return new MyClass { data = 999 }; } } public override string ToString() { return data.ToString(); } } Then I can pass any function that is expecting a MyClass object a

Interop between F# and C# lambdas

徘徊边缘 提交于 2020-01-27 22:40:56
问题 F# powerpack comes with a set of conversion methods to translate from Func<...> to F# functions, either standard or tupled ones. But is it possible to achieve the opposite: in case you want to call from F# code a C# method that takes Func<...> and want to use native F# lambda expression (e.g. fun x -> some_function_of(x))? If I send a F# function with a signature 'a -> 'b to a C# method that expects Func then F# compiler generates the following error: This expression was expected to have type

Interop between F# and C# lambdas

好久不见. 提交于 2020-01-27 22:39:53
问题 F# powerpack comes with a set of conversion methods to translate from Func<...> to F# functions, either standard or tupled ones. But is it possible to achieve the opposite: in case you want to call from F# code a C# method that takes Func<...> and want to use native F# lambda expression (e.g. fun x -> some_function_of(x))? If I send a F# function with a signature 'a -> 'b to a C# method that expects Func then F# compiler generates the following error: This expression was expected to have type

How to use Map.TryFind?

二次信任 提交于 2020-01-26 04:19:19
问题 When I run the code below I get an error. I am using Map.TryFind and its not working. In console, I get a red line under familyinc.TryFind(tract) and the error below. let data = seq { for (state,work) in statecsv do let (family,income) = familyinc.TryFind(state) let fam = match fam with | Some x -> x | None -> "Not a Record" let inc = match inc with | Some x -> x | None -> "Not an income" yield (state,work,inc,fam) } The ERROR: error FS0001: This expression was expected to have type ''a * 'b'

Find repeating values in List

一曲冷凌霜 提交于 2020-01-26 01:46:06
问题 I want to return true if I find a repeating value in the list let rec repeats L = match L with | [] -> false | x::xs when x = xs.Head -> true | x::xs -> repeats xs;; repeats [1;2;3;4;5] Should return false. But I get this error: System.InvalidOperationException: The input list was empty. at Microsoft.FSharp.Collections.FSharpList`1.get_Head() at FSI_0003.repeats[a](FSharpList`1 L) at <StartupCode$FSI_0004>.$FSI_0004.main@() at main@dm() Stopped due to error What should I do to fix the error?