All Questions
14 questions
0
votes
4
answers
150
views
Functor over multiple levels
I have this lame attempt:
fmap2 :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
fmap2 f f2 = (fmap2 f . fmap f2)
It is supposed to work like this:
fmap2 negate [[1,2], [3]] -- ...
4
votes
3
answers
232
views
Haskell Is there a function for creating every variation of applying a function to a list
I want to create a list of variations of applying a function to every element of a list. Here is a quick example of what I mean.
applyVar f [a, b, c]
>> [[(f a), b, c], [a, (f b), c], [a, b, (f ...
1
vote
2
answers
412
views
How to apply a function in an iterable list
so I am new to OCaml and im having some trouble with lists.
What I have is a List of chars as follows:
let letters = [a;b;c;d]
I would like to know how can I iterate the list and apply a fuction that ...
0
votes
1
answer
36
views
How to add data frames to a list and name them from a user written function
I think I can ask this question without explaining the details of why I am doing it, lets try:
I am writing a function, part of what it does is create a data frame called x. I have a list that I would ...
1
vote
1
answer
575
views
How to generate a list of natural numbers from 1....n?
I am currently trying to, inside my function, generate a list. The user will pass in one parameter, which will be an Int. The function's job is to generate a list, starting from 1, and going up to n. ...
1
vote
1
answer
508
views
How to double elements in an F# list and set them in a new list
I am very new to F# and functional programming in general, and would like to recursively create a function that takes a list, and doubles all elements.
This is what I used to search for a spacific ...
1
vote
2
answers
153
views
Lists in functional programming, more specifically in Haskell
I am studying Haskell and saw this question :
h [] = []
h [x] = []
h (x:y:ys) = (x <= y): (h (y:ys))
the questions are, (1) what is the output type of h? (2) if length of xs is 100 then what is ...
1
vote
2
answers
158
views
Haskell: Change a list of 100 numbers to 10 lists of 10 numbers?
In Haskell, how does one change a list of x numbers into n lists of n numbers?
The first sublist would have numbers first to tenth, second list 11th to 20th...
myFunction :: [Int] -> [[Int]]
1
vote
2
answers
155
views
in R: nest two lists of functions and return combined functions in a list
I have two lists of functions that I try to combine to one list of functions (one nested in the other).
funlist=list()
funlist[[1]] <- function(x1){2*x1}
funlist[[2]] <- function(x2){3*x2}
...
1
vote
6
answers
3k
views
Update the values of a list with their absolute values
Newbie to scala.
I am trying to make this code to work for a few hours now . It is intended to update the List[Int](list of integers) with absolute values of the integers.
Took a long time to figure ...
6
votes
1
answer
158
views
applying a list to a function's arguments
How to write a function in F# for applying a list of values to a function like the Apply (@@) symbol in mathematica (map elements of the list to function arguments)
for example apply f [1;2;3] calls ...
0
votes
2
answers
2k
views
Evaluate function from list in lisp
I need to write a function in lisp with two arguments - list of argumentless functions and list of integers.
I need to evaluate functions from first list in order given by a second, i.e. (fun '(#'a #'...
6
votes
2
answers
21k
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 (...
0
votes
2
answers
247
views
Scheme List Derangement (Rearrangement of sorts)
im trying to write a function in Scheme where i accept a list and return all the different derangements (look below for definition) as a list of lists
derangement: A list where no item is in the same ...