1 2 | nächste Seite |
Gepostet: |
help...in writing code | ||||||||||
given a list of ds of digits, consider the problam of determining a permutation es= magic ds of ds with property that for each k in the range 1<= k<=length es, the decimal number formed the first k digits of es is divisible by k. Formulate a starightforward definistion of magic Please help me do this...I don't know german but if you write just the code for me it would be a great help.... Thank you and Merry Christmas to all of you John |
|||||||||||
Zum Seitenanfang | |||||||||||
Gepostet: |
|||||||||||
Well, jacke is in the holidays, but i tell her, that she has a new post here ;-) So expect an answer in the late evening... | |||||||||||
Zum Seitenanfang | Homepage ICQ | ||||||||||
Gepostet: |
|||||||||||
Hmm, its very difficult to understand. Can you give us an example for each function you have to write (input and output)? And what is given - is it a list of digits (called ds) or sth. other? Heres some code for generating all permutations: perms :: Eq a => [a] -> [[a]] A permutation of a list is a list with the same elements in a different order. The perms function returns a list of all permutations of a list. The empty list has one permutation, itself. If xs is not empty, a permutation is given by picking an element x from xs and putting x at the front of a permutation of the remainder xs\\[x]. (The operation '\\' returns the difference of two lists: xs\\ys is the list xs with each element of ys removed, if its present.) I hope, this will help a little bit ;-) |
|||||||||||
Zum Seitenanfang | |||||||||||
Gepostet: |
|||||||||||
Thank yu for your reply Actually this is all that is given.....i.e. this is the only question given...nothing is associated with it...so one can assume any i/p he wants Your reply has helped quite a bit but even I am confused with what to write for this question... Happy new year regards John |
|||||||||||
Zum Seitenanfang | |||||||||||
Gepostet: |
|||||||||||
Hehe, now i understand the problem ;-) But theres still one question open. Should the formed number be divisible by the index k or by the digit that is at position k? I'll try to code this tomorrow. However, could you write for i/p what it means? I'm not familiar with this abbreviation... |
|||||||||||
Zum Seitenanfang | |||||||||||
Gepostet: |
|||||||||||
isDigit c = c >= '0' && c <= '9' use: Main> magic ['1','2','3'] "123" Main> magic "67" "76" Main> |
|||||||||||
Zum Seitenanfang | |||||||||||
Gepostet: |
|||||||||||
thanks a lot...yeah that is how it should be ....thank you very much....by the way i have a few more questions and was wondering if you are willing to do a few more coding...... Hav a great new year John |
|||||||||||
Zum Seitenanfang | |||||||||||
Gepostet: |
|||||||||||
you can post any other questions ;-) i will try my best... | |||||||||||
Zum Seitenanfang | |||||||||||
Gepostet: |
|||||||||||
Dear Jacke Actually I am doing my undergrad in aberdeen univ and they have given us such difficult questions in the holiday assignment......I want to pass so I need your help By the way...could you email me the answer coz if my professor by mistake sees it online in the public forum...i wil be kicked out of the university...... my email is john.youngalmighty@googlemail.com i hope you understand 1) give haskell and type of definition "merge" that merges two ordered list 2) give type and definition of function "member " such that "member xs x " returns True if "x" is an element of "xs" and False otherwise. thanks |
|||||||||||
Zum Seitenanfang | |||||||||||
Gepostet: |
|||||||||||
mergesort http://www.csc.depauw.edu/~bhoward/courses/0203Spring/csc122/haskintro/ isinlist [] x= False your prof cant find the posts with google ...try it ;-) |
|||||||||||
Zum Seitenanfang | |||||||||||
1 2 | nächste Seite |