Can I somehow cache the i.toString
in this simple definition of function?
def palindrome(i: Int) = i.toString == i.toString.reverse
I want to keep this function simple, w/o a classic multi-line, brace-enclosed function..
An Intermediate Cache or Proxy cache is cache store that sits between the client and the server in the cache chain.
That means each cache line contains 16 bytes. If the cache is 64Kbytes then 64Kbytes/16 = 4096 cache lines.
Implementing a Cache Using a Python Dictionary You can use the article's URL as the key and its content as the value. Save this code to a caching.py file, install the requests library, then run the script: $ pip install requests $ python caching.py Getting article... Fetching article from server...
You could do:
def palindrome(i: Int) = ((s:String) => s == s.reverse)(i.toString)
Well, Scala doesn't have a let statement like some traditional functional languages, but that's largely because val + braces fulfill the same purpose. Are you objecting to the multi-line part or to braces in general? Because it's pretty hard to beat:
def palindrome(i: Int) = { val s = i.toString; s == s.reverse }
Attempts to elide the braces will likely only drive the character count up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With