values 'blah blah blah';
values 'blah megablah';
values 'blah blah blahhhh';
nexttable 'something else'
values 'blah blah blaaaah';
Should be converted to:
table bullshit values 'blah megablah'
table bullshit values 'blah blah blahhhhhh'
nexttable more BS values 'blah blah bllllaah'
And so on, inserting the table-line in front of every other line.
1. I can't use hGetLine with recursion, because I have to add different lines together. Thus I need to put the whole stuff together as a string with hGetContents
2. I can't properly define the parts of the whole textfile as a string, to play around with, as each sentence has varying lengths. Pattern matching with (table, _, _, _, values) is therefore not possible.
I thought of this:
myConvert::[Char] -> [Char] myConvert wholesentence firstpart value = wholesentence ++ init firstpart ++ value where head wholesentence = "table" last tablevalue = ";" head firstpart = "table" last firstpart = "values" head value = "values" last value = ";"
This function put in a recursion IO, would go through my entire string matching:
table bullshit values blah2 values blah3 values blah4
changing it to
table bullshit values blah1, table bullshit values blah2, values blah3
starting over again, just hopping one "blah" further:
table bullshit values blah2, values blah3 values blah4 -->
table bullshit values blah2 table bullshit values blah3, values blah4
This doesn't work, as the definitions in my where clause are overlapping; apparently, input can only be matched to function variables exclusively, not twice. Any idea of what tricks I can use to get around this?
This post has been edited by monkeyC: 29 July 2010 - 09:02 AM