Created
September 2, 2022 22:04
-
-
Save voronoipotato/ae6d53a7a52648a87aed6dd0445fb248 to your computer and use it in GitHub Desktop.
script that is both a powershell script, and a f# script, that invokes the F# script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if false | |
return dotnet fsi --quiet --exec --use:"$(Get-Location)\$($MyInvocation.MyCommand.Name)" -- $args | |
#endif | |
// <# | |
//the first argument is the script name, so we get the tail | |
let args : string array = fsi.CommandLineArgs |> Array.tail | |
let hexByteToAscii (s:string) = | |
System.Convert.ToByte(s,16) | |
|> System.Convert.ToChar | |
let charsToString (chars:char[]) = | |
new string (chars) | |
let hexToAscii (value:string) = | |
value | |
|>Seq.chunkBySize 2 | |
|>Seq.map ( hexByteToAscii << charsToString) | |
|>Seq.toArray | |
|>charsToString | |
let out = (hexToAscii args[0]) | |
printf "%s" out | |
// #> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if false | |
return dotnet fsi --quiet --exec --use:"$(Get-Location)\$($MyInvocation.MyCommand.Name)" -- $args | |
#endif | |
// <# | |
//the first argument is the script name, so we get the tail | |
let args : string array = fsi.CommandLineArgs |> Array.tail | |
let hexByteToAscii (s:string) = | |
System.Convert.ToByte(s,16) | |
|> System.Convert.ToChar | |
let charsToString (chars:char[]) = | |
new string (chars) | |
let hexToAscii (value:string) = | |
value | |
|>Seq.chunkBySize 2 | |
|>Seq.map ( hexByteToAscii << charsToString) | |
|>Seq.toArray | |
|>charsToString | |
let out = (hexToAscii args[0]) | |
printf "%s" out | |
// #> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example f# from https://stackoverflow.com/questions/65477935/f-hex-to-ascii/65479989#65479989