asmodis-rlsm 0.2.0 → 0.2.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/monoid.rb +18 -15
  2. data/lib/rlsm_regexp.rb +1 -1
  3. metadata +1 -1
data/lib/monoid.rb CHANGED
@@ -36,7 +36,7 @@ class Monoid
36
36
  #neutral element is moved to position 0
37
37
  _check_and_rearrange_neutral_element
38
38
  _normalize if options[:normalize]
39
- _create_element_names(options[:names])
39
+ _create_element_names if options[:create_names]
40
40
  end
41
41
 
42
42
 
@@ -405,7 +405,7 @@ class Monoid
405
405
  #somthing to do?
406
406
  return if a == b
407
407
 
408
- check_arguments(a,b)
408
+ a,b = check_arguments(a,b)
409
409
 
410
410
  #create the transposition
411
411
  t = (0...@order).to_a
@@ -419,6 +419,9 @@ class Monoid
419
419
 
420
420
  #swap the rows
421
421
  @bo[a], @bo[b] = @bo[t[a]], @bo[t[b]]
422
+
423
+ #update names
424
+ @names[a], @names[b] = @names[b], @names[a]
422
425
  end
423
426
 
424
427
  def bo_str_after_iso(iso)
@@ -472,6 +475,10 @@ class Monoid
472
475
 
473
476
  @bo = (table.collect! { |e| e.to_i })/@order
474
477
  end
478
+
479
+ #Convert to internal represenation
480
+ @names = @bo.flatten.uniq.sort
481
+ @bo = (@bo.flatten.map { |e| @names.index(e) })/@order
475
482
  end
476
483
 
477
484
  def _check_form_of_binary_operation
@@ -502,19 +509,15 @@ class Monoid
502
509
  one ? transpose(0,one) : raise(Exception, "no neutral element")
503
510
  end
504
511
 
505
- def _create_element_names(names)
506
- if names.kind_of? Array and names.size == @order
507
- @names = names
508
- else
509
- @names = []
510
- char = "a"
511
- @elements.each do |i|
512
- if i == 0
513
- @names << "1"
514
- else
515
- @names << char.clone
516
- char.succ!
517
- end
512
+ def _create_element_names
513
+ @names = []
514
+ char = "a"
515
+ @elements.each do |i|
516
+ if i == 0
517
+ @names << "1"
518
+ else
519
+ @names << char.clone
520
+ char.succ!
518
521
  end
519
522
  end
520
523
  end
data/lib/rlsm_regexp.rb CHANGED
@@ -362,7 +362,7 @@ module RLSM
362
362
  end
363
363
 
364
364
  def to_s
365
- if @parent.nil? or @parent.class == Union
365
+ if @parent.nil? or @parent.class == Union or @paarent.class == Star
366
366
  return @childs.map { |child| child.to_s }.join('|')
367
367
  else
368
368
  return '(' + @childs.map { |child| child.to_s }.join('|') + ')'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asmodis-rlsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.01
5
5
  platform: ruby
6
6
  authors:
7
7
  - asmodis