4/29/2023 0 Comments Babylonian numerals conversion![]() From there you could do 60 ** index (where ** is the power operator in F#).īut ** requires floats, not ints, which means that you need to either initialise or cast all the values in the function as float. Seq.mapi maps each element in the sequence, and provides the index to the mapping function. The fst function returns the first item in that tuple, and Seq.sum does the actual summing. The function will return a tuple of seq, int. The initial state for the accumulator is 1.įor example, the order of calls and results in Seq.mapFoldBack for input (4, 60) i is then multiplied by 60, and this value is then passed to the next item in the sequence. Seq.mapFoldBack iterates through the sequence backwards, and threads an accumulator value through the sequence (in this case, i).įor each element in the sequence, the Babylonian number is computed (by Seq.sumBy, which maps each character to a number and totals the result) and then multiplied by i. ![]() Seq.mapFoldBack combines Seq.map and Seq.foldBack. Ungolfed it would look like this: let s (v:string) = • The
![]()
![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |