Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- display all pythagorean triplets until n
- pyth n = [(x,y,z)|x<-[1..n],y<-[x..n],z<-[x..n], x^2+y^2==z^2]
- -- signum if get 0, standardsize as 0, other number is 1
- signum 0 = 0
- signum n = 1
- -- write a program to read a list of tuples from the user of the form
- -- [(1,"sam",25),(2,"john",24),(3,"mary",26)] and display the list of the form
- -- [(1,25),(2,24),(3,26)]
- mydisplay xs = [(x,z)|(x,y,z)<-xs]
- -- write a program to read a list of tuples from the user of the form
- -- [(2,4),(1,6),(0,3)] and produce the output
- -- [8,6,0]
- myprods xs = [(x*y)|(x,y)<-xs]
- -- check if the list is sorted in ascending
- pairup xs = zip xs (tail xs)
- checkorder xs = and[(x<y)| (x,y)<-pairup xs ]
- -- dot product
- dotpro xs ys = sum [(x*y)|(x,y)<-zip xs ys]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement