Skip to content

Instantly share code, notes, and snippets.

@arsdragonfly
Created January 17, 2021 03:13
Show Gist options
  • Select an option

  • Save arsdragonfly/05784d46648a2d02877c4558cf39e59b to your computer and use it in GitHub Desktop.

Select an option

Save arsdragonfly/05784d46648a2d02877c4558cf39e59b to your computer and use it in GitHub Desktop.
splitting uma in typescript
import * as R from 'ramda'
let points = [31000, 31000, 31000, 7000]
let uma = [30000, 10000, -10000, -30000]
let points_and_uma = R.zip(points, uma)
let grouped_by_tie = R.groupWith((a, b) => a[0] == b[0], points_and_uma)
let process_ties = (ties: [number, number][]) => {
let total_uma = R.sum(R.map(t => t[1], ties))
let average_uma = total_uma / ties.length
return R.map(t => t[0] + average_uma, ties)
}
let scores = R.flatten(R.map(process_ties, grouped_by_tie))
console.log(scores) // [ 41000, 41000, 41000, -23000 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment