<commit_before>// Set up SVG for D3.
var width = 570,
    height = 550;

var svg = d3.select("svg")
    .attr("width", width)
    .attr("height", height)

var SEED_RADIUS = 5;

// Let F_n be the nth Fibonacci number. We can prove by
// induction that \sum_{i=1}^{n}{F_i} = F_{n+2} - 1. Then
// we choose 376 = F_14 - 1 = \sum{i=1}^{12}{F_i}, because
// the outer rim of a sunflower usually has F_12 = 144 seeds.
// See: http://www.proofwiki.org/wiki/Sum_of_Sequence_of_Fibonacci_Numbers
var NUM_SEEDS = 376;

// See: http://en.wikipedia.org/wiki/Golden_angle
var GOLDEN_ANGLE = Math.PI * (3 - Math.sqrt(5));

// Returns { r: radius, phi: angle } using Vogel's formulas.
// See: http://algorithmicbotany.org/papers/abop/abop-ch4.pdf
function place (n) {
  var   C = 7.5,
        r = C * Math.sqrt(n),
      phi = n * GOLDEN_ANGLE;

  return { r: r * Math.cos(phi), phi: r * Math.sin(phi) };
}

// d3.range(start, end) returns the range from start to end - 1.
// We add one back to get 376 elements as intended.
var seeds = d3.range(1, NUM_SEEDS + 1).map(place);

svg.selectAll("circle")
    .data(seeds)
  .enter().append("circle")
    .attr("cx", function(d) { return width / 2 + d.r; })
    .attr("cy", function(d) { return height / 2 + d.phi; })
    .attr("r", SEED_RADIUS);
<commit_msg>Use a lambda for the map that generates the seeds.<commit_after>// Set up SVG for D3.
var width = 570,
    height = 550;

var svg = d3.select("svg")
    .attr("width", width)
    .attr("height", height)

var SEED_RADIUS = 5;

// Let F_n be the nth Fibonacci number. We can prove by
// induction that \sum_{i=1}^{n}{F_i} = F_{n+2} - 1. Then
// we choose 376 = F_14 - 1 = \sum{i=1}^{12}{F_i}, because
// the outer rim of a sunflower usually has F_12 = 144 seeds.
// See: http://www.proofwiki.org/wiki/Sum_of_Sequence_of_Fibonacci_Numbers
var NUM_SEEDS = 376;

// See: http://en.wikipedia.org/wiki/Golden_angle
var GOLDEN_ANGLE = Math.PI * (3 - Math.sqrt(5));

// Returns { r: radius, phi: angle } using Vogel's formulas.
// See: http://algorithmicbotany.org/papers/abop/abop-ch4.pdf
function placeSeed (n, alpha) {
  var   C = 7.5,
        r = C * Math.sqrt(n),
      phi = n * alpha;

  return { r: r * Math.cos(phi), phi: r * Math.sin(phi) };
}

// d3.range(start, end) returns the elements from start to end - 1.
// We add back one to have NUM_SEEDS seeds.
var seeds = d3.range(1, NUM_SEEDS + 1).map(function (n) {
  return placeSeed(n, GOLDEN_ANGLE);
});

svg.selectAll("circle")
    .data(seeds)
  .enter().append("circle")
    .attr("cx", function(d) { return width / 2 + d.r; })
    .attr("cy", function(d) { return height / 2 + d.phi; })
    .attr("r", SEED_RADIUS);

{'fraction_non_alphanumeric': 0.1720510894064613, 'fraction_numerical': 0.03193087903831705, 'mean_word_length': 3.0105421686746987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '302947', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1037, 'n_words': 290}