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
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
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...
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
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 yeH
RUBY! \Write a method called reverse_each_word that takes in a string argument of a sentence and returns that same sentence with each word reversed in place. First solve it using .each Then utilize the same method using .collect to see the difference. For example: reverse_each_word("Hello there, and how are you?") #=> "olleH ,ereht dna woh era ?uoy" Hint: You can't use an enumerator on a string, so how can we turn our string into an array? Hint: How can we...
In Haskell: Write a recursive function fibonacci that computes the n-th Fibonacci number. fibonacci :: Int -> Int Write a recursive function myProduct that multiplies all the numbers in a list. myProduct :: [Integer] -> Integer Using the technique of List Comprehension write a function that would remove even numbers from a list of lists. For Example: given input: [[1,2,3,4], [6,3,45,8], [4,9,23,8]] expected output: [[1,3], [3,45],[9,23]]. Show how the library function replicate :: Int -> a-> [a] that produces a...