You are to create a program, that, given another program, and a position, will make it a quine. Namely, it needs to insert an expression at that point that evaluates to a string that is the programs input. For example:
main=do
putStrLn "Welcome to the open source program, would you like my source code?"
(ans:_) <- getLine
case ans of
'y' -> putStrLn --Quine goes here
'n' -> putStrLn "Okay, Good bye"
_ -> putStrLn "Unrecongnized command. Try again." >> main
Now if I told it to put the source code at (5,24) the result would be.
main=do
putStrLn "Welcome to the open source program, would you like my source code?"
(ans:_) <- getLine
case ans of
'y' -> putStrLn ((\a b->a++(show a)++" "++(show b)++b) "main=do\n putStrLn \"Welcome to the open source program, would you like my source code?\"\n (ans:_) <- getLine\n case ans of\n 'y' -> putStrLn ((\\a b->a++(show a)++\" \"++(show b)++b) " ")--Quine goes here\n 'n' -> putStrLn \"Okay, Good bye\"\n _ -> putStrLn \"Unrecongnized command. Try again.\" >> main\n")--Quine goes here
'n' -> putStrLn "Okay, Good bye"
_ -> putStrLn "Unrecongnized command. Try again." >> main
Clarifications:
- The program you make and the type of programs it act upon may be different if you like.
- Your program may get the position in the program and its source code however it sees fit. You may put the new source code where ever you see fit.
- Obviously, the new program can't simply grab its source code from its file
- You may only insert things at the position the user specifies (so you may not be able to include any new modules in the new program depending on target language)
This is code golf, so shortest answer wins! Let us see how many different languages we can make quine makers for as well.