Search Results

Search found 2 results on 1 pages for 'turingcomplete'.

Page 1/1 | 1 

  • list permutations in haskell

    - by turingcomplete
    So I'm new to haskell and I've been playing with it for a while now. I want to get my function that outputs all list permutations to work. I have written 2 implementations, one works well, the other is giving me an error. Any help would be awesome. This is the first (working) implementation: permute [] = [[]] permute xs = [y| x <- xs, y <- map (x:) $ permute $ delete x xs] This one is giving me an error: permute [] = [[]] permute xs = map (\x -> map (x:) $ permute $ delete x xs) xs and here's the error message: Occurs check: cannot construct the infinite type: t0 = [t0] Expected type: [t0] Actual type: [[t0]] In the expression: map (x :) $ permute $ delete x xs In the first argument of `map', namely `(\ x -> map (x :) $ permute $ delete x xs)' I'd appreciate if someone could explain why I'm getting this error. Thanks

    Read the article

  • 3x3 Average filter in matlab

    - by turingcomplete
    I've written code to smooth an image using a 3x3 averaging filter, however the output is strange, it is almost all black. Here's my code. function [filtered_img] = average_filter(noisy_img) [m,n] = size(noisy_img); filtered_img = zeros(m,n); for i = 1:m-2 for j = 1:n-2 sum = 0; for k = i:i+2 for l = j:j+2 sum = sum+noisy_img(k,l); end end filtered_img(i+1,j+1) = sum/9.0; end end end I call the function as follows: img=imread('img.bmp'); filtered = average_filter(img); imshow(uint8(filtered)); I can't see anything wrong in the code logic so far, I'd appreciate it if someone can spot the problem.

    Read the article

1