Scala function which computes a stream that contains an Arithmetic sequence -


टेस्ट

  परीक्षण ("अंकगणित") {जोर देना (गणना: अरिथमेटिक (5, 10) === 30)}  

मुख्य

  डीईएफ अंकगणित (ए: इंट , बी: इंट): इंट = {val सी = बी - एक वैल तीसरा = बी + सी वेल चौथा = तीसरा सी वैल पांचवीं चौथी = सी पांचवीं सी}   <पी> स्काला में एक  val fibs = fibFrom (1, 1) .take (7)  का उपयोग कर बना सकता है। क्या यह एक धारा का उपयोग करना संभव है जो स्काला में  अंकगणित  दृश्य बनाता है? यदि सकारात्मक है, तो इसे कैसे कार्यान्वित करें? 

एक फाइबोनैचि अनुक्रम एक अंकगणितीय अनुक्रम है और आप जो भी क्रम बना सकते हैं आप चाहते हैं:

  scala & gt; Val s: स्ट्रीम [Int] = 0 # :: s.map (_ + 5) s: स्ट्रीम [Int] = स्ट्रीम (0,?) स्केल & gt; S (10) res0: Int = 50 स्केल & gt; (एस ले लो 10) .toList res1: सूची [इंट] = सूची (0, 5, 10, 15, 20, 25, 30, 35, 40, 45)  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

c# - Create dynamic LINQ query expression at runtime which translates into a parameterized SQL query for nullable types -

cmake - cpack generates RPMs with %files entries that conflict with the RPM spec. How to fix? -