Try implementing Yubaba in Kinx

Former story

I don't do this much, but definitely no one but me does it. .. .. But it's kind of embarrassing.

What is Kinx? Please see the following.

** "The appearance is JavaScript, the brain (contents) is Ruby, (stability is AC / DC)" ** The scripting language Kinx kinx).

code

When I looked at JavaScript version, it was executed on the browser (← it may be natural in a sense ...), so looks JavaScript couldn't show its true character. I had no choice but to make it with full scratch (it's not a big deal).

yubaba.kx


System.println("It's a contract. Write your name there.");
var name = $stdin.readLine();

System.println("Hung.%Is it s? It's a luxurious name." % name);

var nameArray = name.split('');
var index = Integer.parseInt(Math.random() * 1000) % nameArray.length();

var newName = nameArray[index];
System.println("From now on your name is%1%It is. Mind you,%1%That's right. I'll reply when I understand%1%!!" % newName);
It's a contract. Write your name there.
Spirited Away
Hung. Is it Chihiro? It's a luxurious name.
From now on your name is a thousand. It ’s a thousand. I'll reply when I understand, a thousand!!

point

Kinx's String # split is split in UTF-8, so make it an array and then cut out one character.

Not entered

I made it crash.

It's a contract. Write your name there.

Hung. I mean. It's a luxurious name.
Uncaught exception: No one catch the exception.
SystemException: Divide by zero
Stack Trace Information:
        at <main-block>(yubaba.kx:7)

I dare to calculate the remainder to make it crash. Originally the following part,

var index = Integer.parseInt(Math.random() * 1000) % nameArray.length();

This is fine below.

var index = Integer.parseInt(Math.random() * nameArray.length());

This will not crash, but since there are no array elements, nameArray [0] will return undefined and will look like this:

It's a contract. Write your name there.

Hung. I mean. It's a luxurious name.
From now on your name is((null))It is. Mind you,((null))That's right. I'll reply when I understand((null))!!

in conclusion

I enjoyed everyone's stories that have been implemented in various ways. Originally, it's a quality that doesn't do this much, but well, Kinx will not do anything other than me, so I did it with a moment of hesitation.

Thank you to @Nemesis (and others) for providing the material.

Recommended Posts

Try implementing Yubaba in Kinx
Try implementing Android Hilt in Java
Try implementing asynchronous processing in Azure
Try implementing GraphQL server in Java
Try to implement Yubaba in Ruby
Try to implement Yubaba in Java
Try LetCode in Ruby-TwoSum
It's late! Try implementing Android Notification in Java (Beginner)
Try using RocksDB in Java
It's late! Try implementing Android Work Manager in Java (Beginner)
Try implementing signature verification for elliptic curve cryptography in Java
Try calling JavaScript in Java
Try developing Spresense in Java (1)
Try functional type in Java! ①
Try implementing a WebFlux session
Try implementing a WebFlux filter
Try using gRPC in Ruby
Try running ruby-net-nntp and tmail in 2020
Try implementing recaptcha with Jetty embedded.
Try running Selenuim 3.141.59 in eclipse (java)
Try an If expression in Java
Implementing side menus in Swift UI
Try running AWS X-Ray in Java
Try file locking in Ruby directory