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 | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 |
|
---|
7 | namespace 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.