Do you mean rerunning on file changes? This is done using the dotnet file watcher. Unfortunately Microsoft declined to make this work with F# script files. So you will have to place your code in an F# console project to use watch
. Or use a solution like this to watch FSX files for changes.
This sounds like the βauto-runβ capability that https://dotnetfiddle.net/ uses that every compiler should have. Syntax editors a important. Iβve only noticed a few live editing capabilities elsewhere such as in the occurrence of the βlive HTML.β
Is there a specific reason I canβt take this working function and run its results back into the same function, for example, using separate designations, and results βcβ as a new target?
ntwilson, taking from your working example. Do you know why this extended function only works by substituting an actual numeric value for the results connected to the initial established function?
open System
let list = [1;2;3]
let target = 2
let mutable Results = String.Empty
list |> List.iteri (fun i obj β if obj = target then
let c = sprintf β%iβ (i + 1)
Results β c )let d = 2
let list2 = [βAβ;βBβ;βCβ;]
let mutable e = String.Empty
list2 |> List.iteri (fun i obj β if i = d then
let f = sprintf β%d %Aβ i obj
e β f )printf β%sβ e
If Iβm understanding you correctly, youβre asking why d
in your second half has to be a numeric value instead of a string value from the list? Thatβs because on this line
list2 |> List.iteri (fun i obj β if i = d then
youβre equating i
and d
, and i
is always an int. (The iteri
function has type
(int -> 'a -> unit) -> 'a list -> unit
, which means the first variable i
has to be an int
). If you changed that line to
list2 |> List.iteri (fun i obj β if obj = d then
then you could set d
to a string, like "C"
let d = "C"
let list2 = ["A"; "B"; "C"]
let mutable e = String.Empty
list2 |> List.iteri (fun i obj -> if obj = d then
let f = sprintf "%d %A" i obj
e <- f)
printf "%s" e
prints 2 "C"
I would like to automate the second results dependent on the first results, however, so is there an a priori for defining d = Results and using (d:int), (Results:int), or something like Int32.TryParse (Results) so that the following function will translate the first functions results into an integer?
Ah, so you want Results
from your first block to be the target index for the 2nd block (d
)? The int
function will do the conversion for you:
open System
let list = [1;2;3]
let target = 2
let mutable Results = String.Empty
list |> List.iteri (fun i obj β if obj = target then
let c = sprintf β%iβ (i + 1)
Results β c )
let d = int Results
let list2 = [βAβ;βBβ;βCβ;]
let mutable e = String.Empty
list2 |> List.iteri (fun i obj β if i = d then
let f = sprintf β%d %Aβ i obj
e β f )
printf β%sβ e
Or you could just leave Results
as an int:
open System
let list = [1;2;3]
let target = 2
let mutable Results = -1
list |> List.iteri (fun i obj β if obj = target then Results β i + 1 )
let d = Results
let list2 = [βAβ;βBβ;βCβ;]
let mutable e = String.Empty
list2 |> List.iteri (fun i obj β if i = d then
let f = sprintf β%d %Aβ i obj
e β f )
printf β%sβ e
Totally kick@#$!!! I chose to go with your second solution modified if statement i=d to i=(d-1) for calibrating purposes and excluded %d and i from its sprintf for accuracy. Thanks ntwilson! Iβm tabbing your terms as completely solved.