How to do string concatation to make a list [closed] - haskell

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Let I have two string. Say, "learn" and "haskell". How can make them list like ["learn","haskell"]

makeListFromTwoThings :: a -> a -> [a]
makeListFromTwoThings x y = [x,y]
Edit: I am assuming you want a function that does this generically. If you want to do this in the Haskell shell then it seems like nothing is stopping you from typing ["learn","haskell"] directly. If you are trying to solve some more general problem directly in the shell then let us know the details of that problem.

Related

Prove Transitivity in Haskell semantics [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I am learning semantics of Haskell and there I came across this question:
I have tried it but still unable to conclude the answer. It will be great if someone explains me how to prove this one. Thank you.
Just a sketch -> Since pn(s) for fixed n is morphism Ninf -> N , that is set of Integers into Integer, this proof can be simplified using this relation into proof of transitivity over integers
[1,0,0 .. ] -> [2,0,0 ..] -> [3,0,0 ..] -> ...
I am sure you can find even more interesting one

In Perl, what is the efficient way to replace a String dynamically with something else? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a file containing many lines like
"resourcename" : "myfile.pdf",
I want to replace everywhere myfile.pdf with an URL like http://somedomain.com/myfile.pdf. But the file name keeps changing. So if myfile.pdf becomes yourfile.pdf, I want to replace it with http://somedomain.com/yourfile.pdf.
What is an efficient way to do global replacement(/g) without affecting the file's encoding like UTF-8?
Thanks

How can i fix the haskell hugs error Instance of Integral Bool required for definition of [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am writing a haskell module for hugs and i get the error shown in the title.
What does this mean and how do i fix this?
the code in question is the second line
and1 :: [Bool] -> Bool
and1 [] = True
This is the first part of the module after the module declaration itself.
The error says that you're trying to use a Bool as an integral, a typeclass allowing most of the operations you'd expect to be on Integer. However, the code you've posted is error free.
Without the rest of the code this is impossible to diagonose. But did you perhaps add a space between and and 1? Eg and 1 [] = True

Determining whether one string is a cyclic rotation of another? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to solve the following problem:
Give a linear-time algorithm to determine if a text T is a cyclic rotation of another string T'. For example, arc and car are cyclic rotations of each other.
I have no idea where to start. How can I solve this problem?
As a hint: if x and y have the same length, then x is a cyclic rotation of y iff x is a substring of yy. Try proving this and using this as the basis for your algorithm.
Hope this helps!

How to split given string in line by line in unix [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Consider the following string "google" . I want to split the following string as below using simple bash script. please help me out.
g
o
o
g
l
e
Another solution with fold :
echo "google" | fold -w1

Resources