code_junkie

Simple haskell string manage

Nov 10th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. subs :: String -> String -> String -> String
  2. -- example:
  3. -- subs 'x' "x^3 + x + sin(x)" "6.2" will generate
  4. -- "6.2^3 + 6.2 + sin(6.2)"
  5.  
  6. import Text.Regex(mkRegex, subRegex)
  7.  
  8. subs :: String -> String -> String -> String
  9. subs wildcard input value = subRegex (mkRegex wildcard) input value
  10.  
  11. import Text.Format
  12. format "{0}^3 + {0} + sin({0})" ["6.2"]
Add Comment
Please, Sign In to add comment