![]() Zero, zip, zilch - how often has a question been answered by one of these words? Countless, no doubt. In the story of zero, something can be made out of nothing. Today, zero is perhaps the most pervasive global symbol known. ![]() Using Seq.mapi it can be done like this for 139 bytes: let f(v:string)=v.Split ' '|>Seq.rev|>Seq.mapi(fun i r->Seq.sumBy(fun c->match c with|'10.0|'T'->1.0|_->0.0)r*(60.0**float i))|>Seq.From placeholder to the driver of calculus, zero has crossed the greatest minds and most diverse borders since it was born many centuries ago. The entire function will return a float, which (in my opinion) is a little messy. 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. |