Skip to content

nunorc/Reducer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Reducer

A simple tool developed in Haskell to reduce a sequence of elements, represented by strings, to a simple expression by finding repeating patterns.

For a live demo visit: http://reducer.nrc.pt.

Example

Using ghci

Using ghci, to reduce the sequence ["a","a","b","c","a","b","c"]:

*Reducer> let (expr,patterns) = reduce ["a","a","b","c","a","b","c"]

The final reduced expression is:

*Reducer> expr
["a","P0","P0"]

And the patterns found are:

*Reducer> patterns
[("P0",["a","b","c"])]

Using the command line

You can use the main.hs program to build a GraphViz representation of the reduced expression. The input expression should be stored in a JSON file:

$ cat ex/input.json 
["a","a","b","c","a","b","c"]

run the program using for example runhaskell, giving as argument the input file, and saving the output to a new file:

$ runhaskell main.hs ex/input.json > ex/expr.dot

Now use the dot tool from GraphViz to create a PNG file for example:

$ dot -Tpng ex/expr.dot > ex/expr.png

You should see something similar to the image below:

Example

About

Developed by: Almeida, J.J, Oliveira, J.N., and Carvalho, N.R.

About

a simple tool for reducing expressions to a simpler form in Haskell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published