5

1 Problem, 4 More Programming Languages (Python vs Kotlin vs F# vs Wolfram)

 3 years ago
source link: https://www.youtube.com/watch?v=6-mk6OpcUdM
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
0:00 / 12:23

1 Problem, 4 More Programming Languages (Python vs Kotlin vs F# vs Wolfram)

30,154 views
•Apr 11, 2021

20 Comments

Sort by
default-user=s48-c-k-c0x00ffffff-no-rj
Add a public comment...
I've started learning APL because of your videos. Currently I've done the phase 1 problems of 2021 competition.

1 week ago

I wonder how performant all these magic operators are, probably a topic for a future video!

1 week ago

Thanks for the updated video and the 4 more programming languages! Btw. in Kotlin, scan is deprecated and is replaced by runningReduce and runningFold. Also, you can reference the plus-operator with Int::plus. Your Kotlin solution could when look like this :

fun maxDepth(s: String) = s .map { when (it) { '(' -> 1; ')' -> -1; else -> 0 } } .runningReduce(Int::plus) .max()

Read more 1 week ago (edited)

Funny you mention the rust scan allowing you to terminate. In F# we do this with Seq.unfold, which has that very semantic. Very useful for infinite iteration.

6 days ago

As of python 3.10 Guido has approved structured pattern matching (after blocking it a decade and a half 🙈)!

I think it makes the imperative approach surprisingly readable!

def max_depth(s:str) -> int: result = 0 depth = 0

for char in s: match char: case '(': depth += 1 case ')': depth -= 1 result = max(depth, result)

return result

Read more 6 days ago (edited)

Kotlin version should have used a Sequence, with is equivalent to Java Stream api. Current Kotlin code is less efficient as it eagerly collects between operator functions, which uses more time and space. Also it could have used an extension function : fun String.maxDepth() : Int = ...

1 week ago (edited)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK