<commit_before>import React, { Component } from 'react'
import { Table } from 'react-bootstrap'
import _ from 'lodash'

import { enumFromTo } from '../../utils'
import { filters } from '../../ship-filters'

const scan = (xs, acc, zero) => {
  const ys = new Array(xs.length+1)
  ys[0] = zero
  for (let i=0; i<xs.length; ++i) {
    ys[i+1] = acc(ys[i],xs[i])
  }
  return ys
}

class CostTable extends Component {
  render() {
    const {
      shipCostListByFilter,
      fuelPercent,
      ammoPercent,
    } = this.props
    const fuelCostFactor = fuelPercent / 100
    const ammoCostFactor = ammoPercent / 100
    return (
      <Table
        style={{tableLayout: 'fixed', margin: 10}}
        striped bordered condensed hover>
        <thead>
          <tr>
            <th>
              Type
            </th>
            {
              enumFromTo(1,6).map(x => (
                <th key={x} style={{width: '14%'}}>{x} ship(s)</th>
              ))
            }
          </tr>
        </thead>
        <tbody>
          {
            _.tail(filters).map(flt => {
              const {id, title} = flt
              // sort and select first 6 ships with lowest cost
              const shipCostList = _.take(
                shipCostListByFilter[id]
                  .map(s => {
                    const {fuelCost, ammoCost} = s.computeCost(fuelCostFactor,ammoCostFactor)
                    return {...s, fuelCost, ammoCost, nameList: [s.shipName]}
                  })
                  .sort( (x,y) => (x.fuelCost+x.ammoCost) - (y.fuelCost+y.ammoCost) ),
                6)
              const plusCost = (x,y) => ({
                fuelCost: x.fuelCost + y.fuelCost,
                ammoCost: x.ammoCost + y.ammoCost,
                nameList: [...x.nameList, ...y.nameList],
              })
              const accumulatedCostList = scan(
                shipCostList,
                plusCost,
                {fuelCost: 0, ammoCost: 0, nameList: []})
              return (<commit_msg>no need of making 'all' a special filter<commit_after>import React, { Component } from 'react'
import { Table } from 'react-bootstrap'
import _ from 'lodash'

import { enumFromTo } from '../../utils'
import { filters } from '../../ship-filters'

const scan = (xs, acc, zero) => {
  const ys = new Array(xs.length+1)
  ys[0] = zero
  for (let i=0; i<xs.length; ++i) {
    ys[i+1] = acc(ys[i],xs[i])
  }
  return ys
}

class CostTable extends Component {
  render() {
    const {
      shipCostListByFilter,
      fuelPercent,
      ammoPercent,
    } = this.props
    const fuelCostFactor = fuelPercent / 100
    const ammoCostFactor = ammoPercent / 100
    return (
      <Table
        style={{tableLayout: 'fixed', margin: 10}}
        striped bordered condensed hover>
        <thead>
          <tr>
            <th>
              Type
            </th>
            {
              enumFromTo(1,6).map(x => (
                <th key={x} style={{width: '14%'}}>{x} ship(s)</th>
              ))
            }
          </tr>
        </thead>
        <tbody>
          {
            filters.map(flt => {
              const {id, title} = flt
              // sort and select first 6 ships with lowest cost
              const shipCostList = _.take(
                shipCostListByFilter[id]
                  .map(s => {
                    const {fuelCost, ammoCost} = s.computeCost(fuelCostFactor,ammoCostFactor)
                    return {...s, fuelCost, ammoCost, nameList: [s.shipName]}
                  })
                  .sort( (x,y) => (x.fuelCost+x.ammoCost) - (y.fuelCost+y.ammoCost) ),
                6)
              const plusCost = (x,y) => ({
                fuelCost: x.fuelCost + y.fuelCost,
                ammoCost: x.ammoCost + y.ammoCost,
                nameList: [...x.nameList, ...y.nameList],
              })
              const accumulatedCostList = scan(
                shipCostList,
                plusCost,
                {fuelCost: 0, ammoCost: 0, nameList: []})
              return (
{'fraction_non_alphanumeric': 0.1332836932241251, 'fraction_numerical': 0.009928021841648052, 'mean_word_length': 1.4558196221815967, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5154867', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1215, 'n_words': 285}