Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/16 22:57:11 (7 years ago)
Author:
pkimmesw
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Tests/Benchmark/ExampleConverter.cs

    r14398 r14513  
    1 using System.Linq;
     1namespace HeuristicLab.Tests.Benchmark
     2{
     3  using System.Linq;
    24
    3 namespace HeuristicLab.Tests.Benchmark
    4 {
    5     public static class ExampleConverter
     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)
    612    {
    7         private const char ArrayValueSeparator = ' ';
     13      return long.Parse(str);
     14    }
    815
    9         private static readonly char[] arraySymbolTrim = new[] { '[', ']' };
     16    public static long[] Integers(string str)
     17    {
     18      var values =
     19        str.Trim(arraySymbolTrim).Split(ArrayValueSeparator).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
    1020
     21      var result = new long[values.Count];
    1122
    12         public static long Integer(string str)
    13         {
    14             return long.Parse(str);
    15         }
     23      for (var i = 0; i < result.Length; i++) result[i] = Integer(values[i]);
    1624
    17         public static long[] Integers(string str)
    18         {
    19             var values = str
    20                 .Trim(arraySymbolTrim)
    21                 .Split(ArrayValueSeparator)
    22                 .Where(s => !string.IsNullOrWhiteSpace(s))
    23                 .ToList();
    24 
    25             var result = new long[values.Count];
    26 
    27             for (var i = 0; i < result.Length; i++)
    28             {
    29                 result[i] = Integer(values[i]);
    30             }
    31 
    32             return result;
    33         }
     25      return result;
    3426    }
     27  }
    3528}
Note: See TracChangeset for help on using the changeset viewer.