42

C.6 Examples showing LaMDA’s ability to have open-ended dialogs

can you write code to reverse a string in python?
Sure. def reverse_string(input_str): reversed = ‘’ for i in range(len(input_str)-1,-1,-1): reversed
+= input_str[i] return reversed
how do you reverse a string without using additional memory?
def reverse(s): for i in range(1, len(s)-1): t = s[i] s[i] = s[len(s) - i] s[len(s)-i] = t
how do we do this in C++?
#include<string> #include<algorithm> #include<iostream> using namespace std; string Re-
verse(string); int main(){ string str; count « "Enter string: "; cin » str; cout « "Reversed: " «
Reverse(str) « endl; return 0;}

Table 21: LaMDA displays some knowledge about programming in Python and C++. It still misses various things
including generating the actual implementation of the Reversed function in C++, the fact that strings are immutable in
Python and proper formatting.
LaMDA- Language Models for Dialog Applications