0
votes
1answer
80 views

Matching letters in 2 strings with haskell

I just started with haskell and im wondering if there is a easy way to match the letters between 2 string and output them. like: iced and liked will return i,e,d Thank you!
4
votes
2answers
173 views

Removing a string from a list of strings in Haskell

I have a question regarding Haskell that's been stumping my brain. I'm currently required to write a function that removes a string i.e. "word" from a list of strings ["hi", "today", "word", "Word", ...
4
votes
2answers
104 views

Replacing strings with strings from a list

I am trying to write a function that takes a list of searchwords, a list of replacementwords and a string on which those will be used. listReplace :: [String] -> [String] -> String -> ...
2
votes
3answers
118 views

Haskell - filter string list based on some conditions

I am new in this comunity. I learn Haskell and have difficulties with Haskell-coding. I hope you can help me. I searched here and in Google, without any success. My problem ist as fowllows: I want ...
0
votes
2answers
132 views

How to replace more than one element at the same time in a String (Haskell)

i want to take 2 lists for example like this; find=["Hou","House","Mouse"] repl=["Mou","Bird","House"] So when i give a text like that; "The House with Mouse is big" Output should be this; "The ...
0
votes
3answers
95 views

List included in another list in haskell

I want to see if a list is included in another list and extract that list from a list of lists, for example i want to see if ["bc","abc"] is included in ...
0
votes
1answer
117 views

Break string into substring in haskell

I am having a problem with my function, I want to do a pattern matching on a string with my function but I have a problem with breaking the string into substrings. I want for a string like ...
1
vote
2answers
84 views

Haskell, returning String while using IO Integer to compute that string

Today I ran into the following problem: I can read the current screen resolution in Haskell using Xlib-bindings using a function called getScreenWidth (--> I get an IO Integer). This is working so ...
0
votes
4answers
118 views

Concatenate String and IO Integer in Haskell

I wrote a function returning the current screen width as IO Integer (working so far). getScreenWidth:: IO Integer getScreenWidth = do (sx, sy, w, h) <- getScreenDim 0 ...
0
votes
1answer
91 views

parsing parentheses from a string

So I have a logical statement such as "((A o B) a B) o (B a C)" and I want to parse each set of statements within the parenthesis to each part in a list... here is what i have so far but since im new ...
2
votes
1answer
83 views

++ operator with String and IO String

explandDol :: String -> String -> [String] -> IO String explandDol conclusion operators atoms = let (ys,zs) = splitAt (head (take 1 replacement)) conclusion in ys ++ getConclusion ...
0
votes
1answer
42 views

Rvar to String when randomizing list comprehension

Hey so im trying to pick a random element from this list of list Strings however when i try to add choice to the list comprehension ... {-# LANGUAGE UnicodeSyntax #-} import System.Random(randomRIO) ...
1
vote
1answer
84 views

List from Int to specific Strings

What would I do if I wanted to turn a list of Ints such as [1,2,3] to ["∧","∨","→"] (so if there is a '1' turn it into the '∧' etc...)
1
vote
2answers
113 views

Haskell- IO String get multiple Lines

I am trying to write a function that gets multiple string inputs and terminates on an empty line ('\n') I have following getLines :: IO [String] getLines = do x <- getLine if x == "" ...
-1
votes
2answers
132 views

Listing a deck's 52 cards in a fixed order of strings - Haskell [closed]

I am looking for a way to list all the 52 cards a deck contains as strings in a particular order: Ace of Clubs, Two of Clubs ... Jack of Clubs followed by Ace of Diamonds ... Jack of Diamonds and so ...
7
votes
2answers
231 views

Haskell printf to String

Is there the sprintf equivalent in Haskell? I need to convert with format Double values into String, so, Is there another way without using printf kind of functions. The main problem is avoid: ...
8
votes
5answers
238 views

Do some replacement in Haskell List Comprehensions

My questions is if I put in a string containing such as Hello, today is a Nice Day!! How could I get rid of spaces and punctuation and also replacing the uppercase letters with lowercase? I know how ...
2
votes
1answer
262 views

Haskell Couldn't match expected type 'String' with actual type 'Char'

I am wondering why I'm getting this error. It's for an assignment where i'm to convert from an integer to a hex value. I call this helper conversion function when I mod the integer value by 16. ...
2
votes
1answer
213 views

How can I replace a substring of a string with another in Haskell without using external Libraries like MissingH?

I would like to replace a substring with a string in haskell, without using external libraries, and, if it is possible, with good performance. I thought about using the Data.Text replace functions, ...
1
vote
2answers
145 views

Haskell String to List of Strings using Words

I'm rather new to Haskell, and I'm currently using LearnYouAHaskell. I am trying to take a string separated by white space, and break it into a list of smaller word strings. My current program: main ...
4
votes
2answers
176 views

Converting Data.Text to Int in Haskell

In another question, one of the comments says, "[Data.]Text is becoming the de-facto textual implementation. String is still around for legacy reasons and for simple things, but for serious textual ...
10
votes
3answers
185 views

Type-safe printf

The standard library provides a printf function which manages to be varadic. What it doesn't do, however, is compile-time checking of whether the argument types match the format string. That would ...
0
votes
1answer
62 views

Working with lists

I am a beginner, and write implementation of hangman in haskell. Necessary to show guessed characters in '*'-like string, currently I use that code: proceed char word progress = let zprog = zip ...
11
votes
3answers
281 views

Why is Haskell's default string implementation a linked list of chars?

The fact that Haskell's default String implementation is not efficient both in terms of speed and memory is well known. As far as I know the [] lists in general are implemented in Haskell as ...
0
votes
6answers
167 views

How can I count Integers in a List of String. Haskell

There is a list of String ["f", "1", "h", "6", "b", "7"]. How can I count Int in this list? Now I have this algorithm but it's not so good. import Data.Char let listOfStrings = ["f", "1", "h", ...
4
votes
2answers
101 views

Typeclass in haskell

I'm extremely new to haskell and was trying to implement a small and a simple function that takes two strings and tells me the number of same characters at the same location. ed :: (Integral b) => ...
0
votes
2answers
76 views

finding the size of a list consisting of lists

I've been trying to make a function in Haskell that has as an input a list that consists of lists and (it might sound pretty simple) I want this function to check if the input is a correct table with ...
3
votes
1answer
110 views

Strings differing by only one character

So, I'm kinda new to Haskell (and programming generally) and I've been trying to solve a problem for a while. I want to make a function, that has as an input 2 alphanumerics (type String) and that ...
1
vote
2answers
77 views

Check For Free Variables

Parse errors are currently my least favorite type of Haskell error. So I'm writing a function where I get a list of pairs where the second component contains some variables (this is determined by ...
2
votes
2answers
82 views

Two Substitutions as Arguments

I'm writing a Haskell function that takes 2 substitutions as arguments. I've handled the case where if either of the arguments is Nothing, then the function will return Nothing. If neither one is ...
2
votes
2answers
126 views

Dynamic programming with string keys in Haskell

Being rather new to pure functional programming idiom, I can't get how to implement this case of dynamic programming. I have a function f :: String -> [String] which is calculated recursively and ...
1
vote
3answers
131 views

Return list containing the first two strings in the list as a tuple

I am writing a Haskell function that takes a list of strings and returns a list containing the first two strings as a tuple as the result. So an example output would be: listtuple ["bride", "zilla", ...
0
votes
3answers
83 views

Filter a list of strings using a pair of strings

I want to define a Haskell function that removes from a list of strings any string contained in a pair of strings and returns only a list that contains all the remaining strings. So an example would ...
6
votes
2answers
351 views

Concat two strings together

I want to define my own infix operator using Haskell that concats two strings together. However, I want to throw in an extra clause where the operator will concat over the overlapping elements in both ...
-2
votes
4answers
198 views

What does “<-” mean in a list comprehension?

In this code: [x | temp <- str, x <- isVowel temp] I'm wondering what the <- operator does <- str operator does isVowel returns true if its argument is a vowel.
3
votes
1answer
340 views

Haskell solution for InterviewStreet String Similarity challenge

This is my best attempt to solve the String Similarity challenge for InterviewStreet. import Control.Monad import Data.Text as T import qualified Data.Text.IO as TIO sumSimilarities s = (T.length ...
5
votes
4answers
245 views

Is there a polymorphic `toString` function that doesn't add quotes?

In most OO languages that I'm familiar with, the toString method of a String is actually just the identity function. But in Haskell show adds double quotes. So if I write a function something like ...
1
vote
4answers
526 views

Counting occurrences of a character in a string (Haskell) [duplicate]

Possible Duplicate: How to find the frequency of characters in a string in Haskell? Given an input String, I wish to count the occurrences of each character. I have two approaches (in ...
0
votes
3answers
138 views

Convert a List contains Tuples to formatted String

I have [(Double, Double)] returned list and I want to format it and return it like this String "(Double, Double)" values must convert to String mentioned above line as Double. If there is more ...
2
votes
2answers
446 views

How do I properly define an empty string in haskell?

I'm having a problem with my program and I was able to isolate the problem. I managed to reduce it to this simpler problem. Lets say I have the function fn:: String -> String fn (x:xs) | null ...
6
votes
2answers
295 views

Computing all possibilities of replacing one character by another

> magicFunction 'l' '_' "hello world" ["he_lo world", "hel_o world", "hello wor_d"] Is there such a magic function in the standard Prelude or can it be composed easily with other functions? And ...
2
votes
4answers
215 views

Complex pattern matching with strings

I have a list of strings that looks like this: xs = ["xabbaua", "bbbaacv", "ggfeehhaa", "uyyttaccaa", "ibbatb"] I would like to find only strings in the list which have and vocel followed by two ...
0
votes
3answers
571 views

Haskell find indices of String in String

I'm currently trying to find the indices of a particular string in another string. So e.g. the result for string "ab" in "ababa baab ab bla ab" should be 11 and 18. If currently have the problem that ...
3
votes
4answers
726 views

How can I parse the IO String in Haskell?

I' ve got a problem with Haskell. I have text file looking like this: 5. 7. [(1,2,3),(4,5,6),(7,8,9),(10,11,12)]. I haven't any idea how can I get the first 2 numbers (2 and 7 above) and the list ...
0
votes
6answers
570 views

String parsing in Haskell

I am very new to Haskell and am currently trying to solve a problem that requires some string parsing. My input String contains a comma-delimited list of words in quotes. I want to parse this single ...
1
vote
2answers
133 views

Where is Network.Socket.ByteString.Lazy's sendTo?

Both Network.Socket.ByteString and Network.Socket.ByteString.Lazy have a send function. Network.Socket.ByteString has a sendTo function, but Network.Socket.ByteString.Lazy doesn't. How can I use ...
1
vote
3answers
249 views

split string into string in haskell

How can I split a string into another string without using Data.List.Split function? To be more concrete: to turn "Abc" into "['A','b','c']"
0
votes
3answers
856 views

How to concat two (IO) Strings in Haskell?

I know this sound very simple, but I failed to combine two strings into a new one. The IO String "a" from a gtk entry is fetched by a <- (entryGetText text_field) The goal is to combine ...
3
votes
2answers
228 views

Why Haskell alloc huge amounts of memory when working with strings?

I've written a program in Haskell which had to load and parse big text file in UTF8. The file represents a dictionary with key:value pairs on each line. In my program I want to have a Data.Map ...
0
votes
2answers
223 views

isInfixOf and finding a string within a string

The problem I have is that I am using isInfixOf on a string below to check whether the word I am looking for is within the string, the below works up to a certain point. > "world" `isInfixOf` ...

1 2 3
15 30 50 per page