Example:
Hello as olleh or [1,3,4,5] as [5,4,3,1].
reverseData :: [b] -> [b] --function declaration
--function definition
-- ++ is concatenation operator
reverseData [] = []
reverseData (a:input) = reverseData input ++ [a]
main = do
print(reverseData "hello") --calling a function
print(reverseData [1,3,4,5])
Output
"olleh" [5,4,3,1]
Write a function in HASKELL to reverse a string (or list) without using the built-in reverse...
Using C,
Write a function reverse which takes a string as an argument, reverses the string and returns the reversed string. Note; you should not return a string that you created inside the reverse function! For example: Test char str[]-"hello" printf("%s", reverse (str)); Result olleh
Write a program in MIPS to accept a string from a user, reverse that string and print it out to the user. You must write a procedure that performs the reversal task. Example: Please Enter a String: Hello How Are You Reversed String: uoY erA woH olleH
Write a function that takes a string as a parameter and returns a new string that is the reverse of the old string. Python from test import testEqual def reverse(s): return s testEqual(reverse("hello"),"olleh") testEqual(reverse("l"),"l") testEqual(reverse("follow"),"wollof") testEqual(reverse(""),"")
In Matlab and not using any built in functions write a function that will take in a word and a specific letter. It will then return a list of all the positions in the word where that letter exists. function indexes = find_letter_positions( word, letter ) Example of output. >> find_letter_positions('hello', 'h') ans = [ 1 ]; >> find_letter_positions('hello', 'l') ans = [ 3 4 ]; >> find_letter_positions('hello', 'z') ans = [ ]; % an empty array
Haskell Function program Write a function negateOdds that takes a list of integers and returns a list of integers with all of the odd integers negated. negateOdds :: [Integer] -> [Integer] example: [1,2,3,4,5] should return [-1,2,-3,4,-5]
In HASKELL Write a function that will delete leading white space from a string. cutWhitespace [" x","y"," z"] ans: ["x","y","z"] You are allowed to use any higher order function/List Comprehension(if you want to use) to solve this problem.
C++ NEED HELP WITH MY REVERSE STRING FUNCTION IN LINK LIST A function Reverse, that traverses the linked list and prints the reverse text to the standard output, without changing the linked list. ( Pass the linked list by value, you have the freedom to create a doubly linked list that is a copy of the original list in your program before you call the function) #include "pch.h" #include <iostream> #include <string.h> #include <string> using namespace std; #define MAX 512...
**Must be done in Haskell** Write the following function: check :: String -> String Which takes in a string with multiple parentheses, brackets and curly brackets and check if they are correct. If they are correct output the string "Correct", and if not output "Wrong" They must only be matched against the same type, ie "({)}" should not be correct. It should not matter that the string contains other letters in it
Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text.Ex: If the input is:Hello there Hey quitthen the output is:ereht olleH yeHThere is a mistake in my code I can not find. my output is : ereht olleH ereht olleHyeHHow can I fix this?I saw some people use void or the function reverse but we didnt...
Write a program in C to reverse a string using recursion. For example: reverse("abcde", ...) -> "edcba" void reverse(char* str, int i, int s) { } provide output and main please