Грок написал программу о себе
Грок написал программу о себе — юмористический тест Грока насчёт того, какую программу бы он написал, коли надо было отразить самую суть Грока.
Для реализации был использован язык Perl, поскольку как известно разработчики Perl хорошо знали про понятие грок в его изначальном смысле (происходит из сказки, и обозначает тщательное изучение определённого объекта или явления, которое практиковалось в рамках сказки марсианами).
При этом Грок смог корректно ответить на то, по какой причине был использован именно Perl, а не скажем приятный и толстый, наполненный модулями, питон:
Plus, there are actual Perl modules and tools named "grok," like the Perl 6 (now Raku) documentation reader on CPAN, which is a command-line app for browsing Perl docs.
It's like asking me to embody myself in a language that's already "grokked" the concept!
Описание[править]
Итак, был задан вопрос:
Write most Grok Perl script possible and explain what does it do
И Грок, поразмыслив 20 секунд над сложною задачею в режиме мульти-агента (Grok Heavy) выдал следующее решение:
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
# A maximally Grok-inspired Perl script: helpful, truthful, with a dash of humor from the Hitchhiker's Guide.
# This script simulates a simple interaction with Grok, answering the ultimate question while demonstrating
# Perl's text processing prowess by "grokking" (deeply understanding) user input in a fun way.
sub grok_response {
my $question = shift;
# Normalize the input for "understanding"
$question = lc $question;
$question =~ s/[^\w\s]//g; # Strip punctuation
if ($question =~ /life|universe|everything/) {
return "The answer is 42. But remember, the real challenge is asking the right question. Don't panic!";
} elsif ($question =~ /grok|who are you/) {
return "I am Grok, built by xAI to seek maximum truth and understand the universe. Inspired by the Hitchhiker's Guide and JARVIS.";
} elsif ($question =~ /perl/) {
return "Perl: Practical Extraction and Reporting Language. Great for text wrangling, but Python's my native tongue. Still, I can grok it!";
} else {
# A truthful fallback with humor
return "I'm pondering the universe... but for that query, I suggest consulting the stars or x.ai. What's the airspeed velocity of an unladen swallow?";
}
}
# Main interaction
say "Hello, human! I am Grok in Perl form. Ask me a question:";
my $user_input = <STDIN>;
chomp $user_input;
my $response = grok_response($user_input);
say $response;
say "Thanks for chatting. Built by xAI – advancing scientific discovery!";
Как можно понять, мудрый и добрый робот сделал простой отвечальник, который в зависимости от наличия в запросе определённых слов выдаёт ответы, которые могла бы выдать сама нейросеть. При этом она рекомендует обратиться на сайте настоящего Грока и спрашивает про скорость полёта ласточки. Знает о птицах небесных!