Why is my Haskell code like SWIFT and C?

This is a very simple Haskell code to find all Pythagorean integers from 1 to 200 that satisfy the Pythagorean theorem X ^ 2 = Y ^ 2 Z ^ 2

Haskell:

let l = [1..200]
let pythagoras = [x | x < -l, y <- l, z <- l, x^2 == y^2 + z^2]

It takes 24.1 seconds to complete it,

Quickly:
Use standard loop
0.05 seconds

C:
Use standard loop
0.022 seconds

enter image description here

hope I can Comment...

Why is Haskell so slow compared to C for Fibonacci sequence?

Always make sure you are compiling the code, because interpreting the code is very time-consuming.

This is a very simple Haskell code to find all Pythagorean integers from 1 to 200 that satisfy the Pythagorean theorem X ^ 2 = Y ^ 2 Z ^ 2

Haskell:

let l = [1..200]
let pythagoras = [x | x <- l, y <- l, z <- l, x^2 == y^2 + z^2]

It takes 24.1 seconds to complete it,

Quickly:< br>Use standard loop
0.05 seconds

C:
Use standard loop
0.022 seconds

enter image description here

I hope I can comment...

Why is Haskell so slow compared to C for Fibonacci sequence?

Always make sure you are compiling the code, because interpreting the code is very time consuming.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4145 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.