Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/ExampleConverter.cs @ 14513

Last change on this file since 14513 was 14513, checked in by pkimmesw, 7 years ago

#2665 Added Problem.ProgramSynthesis Project, Fixed Expression Issues, Fixed Code Generation

File size: 681 bytes
Line 
1namespace HeuristicLab.Tests.Benchmark
2{
3  using System.Linq;
4
5  public static class ExampleConverter
6  {
7    private const char ArrayValueSeparator = ' ';
8
9    private static readonly char[] arraySymbolTrim = { '[', ']' };
10
11    public static long Integer(string str)
12    {
13      return long.Parse(str);
14    }
15
16    public static long[] Integers(string str)
17    {
18      var values =
19        str.Trim(arraySymbolTrim).Split(ArrayValueSeparator).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
20
21      var result = new long[values.Count];
22
23      for (var i = 0; i < result.Length; i++) result[i] = Integer(values[i]);
24
25      return result;
26    }
27  }
28}
Note: See TracBrowser for help on using the repository browser.