Convert A String to List in Prolog

25 views
Skip to first unread message

Anaïs Siewe

unread,
Apr 29, 2015, 11:15:04 AM4/29/15
to swi-p...@googlegroups.com

I am a Prolog newbie and am stuck at parsing a string to a list. I have a string of the form. I want to read polynomial as String and convert it into String. I want to convert the input String

2x^3 + x^2 - 4x^1 - 8 

to

[[2,3], [1,2], [-4, 1], [-8, 0]]

 

How can I achieve this functionality?

Stephen Coda

unread,
May 1, 2015, 3:27:00 AM5/1/15
to swi-p...@googlegroups.com
You probably want to learn about DCGs in Prolog, they're useful for this sort of transformation.
Reply all
Reply to author
Forward
0 new messages