Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Sentence.cs @ 15712

Last change on this file since 15712 was 15712, checked in by lkammere, 7 years ago

#2886 Add basic class structure, grammar and grammar iteration.

File size: 710 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6
7namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration {
8  public class SymbolString : List<Symbol> {
9
10    public SymbolString(IEnumerable<Symbol> symbols) : base(symbols) { }
11
12    public bool IsSentence() {
13      return this.All(sym => sym is TerminalSymbol);
14    }
15
16    public int[] GetNonterminalSymbolIndexes() {
17      return Enumerable.Range(0, Count)
18        .Where(i => this[i] is NonterminalSymbol)
19        .ToArray();
20    }
21
22    public override string ToString()
23    {
24      return string.Join(" ", this);
25    }
26  }
27}
Note: See TracBrowser for help on using the repository browser.