में प्रकार के बीच परिवर्तित मैं हास्केल में पाठ का एक केंद्रित स्ट्रिंग वापस जाने के लिए एक सरल समारोह बनाने की कोशिश कर रहा हूँ, लेकिन मैं मुसीबत सिर्फ दोनों ओर डालने के लिए कितना गद्दी पाने के आ रही है। मैं इस है:हास्केल
center padLength string = round ((padLength - (length string))/2)
निम्नलिखित में से कौन त्रुटि देता है:
No instance for (Fractional Int)
arising from a use of '/'
Possible fix: add an instance declaration for (Fractional Int)
In the first argument of 'round', namely
'((padLength - (length string))/2)'
In the expression: round ((padLength - (length string))/2)
In an equation for `center':
center padLength string = round ((padLength - (length string))/2)
मैं कैसे (मूल रूप से) एक डबल (मुझे लगता है कि) एक इंट से परिवर्तित कर सकते हैं?
इसकी आवश्यकता क्यों है? मैं हास्केल –
के लिए थोड़ा नया हूं मैंने अपने उत्तर में यह जानकारी जोड़ दी है :) – ehird