所以我有这4个例子,其中3个是我从这个youtube视频中得到的.
我刚刚参加了关于函数式编程的课程(在Racket中),如果我对F#的基本理解是对的,我就是这样.
let data = [1.;2.;3.;4.]
let sqr x = x * x
// Bad, very bad
let sumOfSquareI nums =
let mutable acc = 0.0
for x in nums do
acc <- acc + sqr x
acc
// Better than above, but may cause stack overflow with very long list
let rec sumOfSquareF1 nums =
match nums with
| [] -> 0.0
| h::t -> sqr h + sumOfSquareF1 t
// much much better, uses tail-recursion, no …Run Code Online (Sandbox Code Playgroud) 我有一个表,其中列有数据,如($23,324.09).如果是$23,324.09,那么我可以将其转换为money,然后是float.但是( )当我尝试时会导致错误.我是否必须将UDF应用于该列,或者是否有另一种方法来转换此类值.
注意:我无法控制数据如何到达该表.
添加更改事件的正确方法是什么?
public static void WatchFileForChange()
{
FileSystemWatcher fsw = new FileSystemWatcher();
fsw.Path = Path.Join(System.Configuration.ConfigurationManager.AppSettings["AccessDBFolder"]);
fsw.Changed += new FileSystemEventHandler(UpdateMDBChange);
fsw.Filter = "*.mdb";
fsw.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
fsw.EnableRaisingEvents = true;
fsw.IncludeSubdirectories = true;
}
private static void UpdateMDBChange(object sender, FileSystemEventArgs e)
{
///sf/answers/213007441/
DateTime lastWriteTime = File.GetLastWriteTime(e.FullPath);
if (lastWriteTime.Ticks - lastRead.Ticks > 100000)
{
TestClient().Wait();
lastRead = lastWriteTime;
}
}
Run Code Online (Sandbox Code Playgroud)
是fsw.Changed += new FileSystemEventHandler(UpdateMDBChange);还是fsw.Changed += UpdateMDBChange;
两种方式似乎都很好。但我不知道是否会出现技术问题。或者如果某种方式不受欢迎。