Skip to content

Commit

Permalink
Fixing problem 1 from issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
brenden committed Apr 22, 2017
1 parent b9aaf82 commit 379a9c9
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions UkkonenAlgorithm.elm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ insert' newChar state =

-- Get the index of the character being inserted
i = Array.length string - 1

in
case activePoint.edge of
-- The case that there's currently no active edge, i.e the active point
Expand Down Expand Up @@ -108,11 +109,12 @@ insert' newChar state =
else
let
newState =
{ state
| tree = newTree2
, activePoint = nextActivePoint state tree
, remainder = state.remainder - 1
}
normalizeActivePoint <|
{ state
| tree = newTree2
, activePoint = nextActivePoint state tree
, remainder = state.remainder - 1
}
in
newState :: (insert' newChar newState)

Expand Down Expand Up @@ -242,7 +244,19 @@ nextActivePoint state tree =
Nothing ->
case activePoint.edge of
Nothing ->
{ activePoint | nodeId = 0 }
{ activePoint
| nodeId = 0
, edge =
if state.remainder == 1 then
Nothing
else
Just
( getChar
(Array.length state.string - state.remainder + 1)
state.string
, state.remainder - 2
)
}

Just ( edgeChar, edgeSteps ) ->
{ activePoint
Expand Down

0 comments on commit 379a9c9

Please sign in to comment.