How to resolve the algorithm Non-decimal radices/Output step by step in the F# programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Non-decimal radices/Output step by step in the F# programming language
Table of Contents
Problem Statement
Programming languages often have built-in routines to convert a non-negative integer for printing in different number bases. Such common number bases might include binary, Octal and Hexadecimal.
Print a small range of integers in some different bases, as supported by standard routines of your programming language.
This is distinct from Number base conversion as a user-defined conversion function is not asked for.) The reverse operation is Common number base parsing.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Non-decimal radices/Output step by step in the F# programming language
Source code in the fsharp programming language
let ns = [30..33]
ns |> Seq.iter (fun n -> printfn " %3o %2d %2X" n n n)
let bases = [2; 8; 10; 16]
ns |> Seq.map (fun n -> Seq.initInfinite (fun i -> n))
|> Seq.map (fun s -> Seq.zip s bases)
|> Seq.map (Seq.map System.Convert.ToString >> Seq.toList)
|> Seq.iter (fun s -> (printfn "%6s %2s %2s %2s" s.[0] s.[1] s.[2] s.[3]))
You may also check:How to resolve the algorithm Hello world/Web server step by step in the Rye programming language
You may also check:How to resolve the algorithm LZW compression step by step in the CoffeeScript programming language
You may also check:How to resolve the algorithm Averages/Arithmetic mean step by step in the Maple programming language
You may also check:How to resolve the algorithm Brownian tree step by step in the Scala programming language
You may also check:How to resolve the algorithm Maximum triangle path sum step by step in the 11l programming language