print("Hello, World!")
console.log("Hello, World!")
print("Hello, World!")
console.log("Hello, World!")
main = putStrLn "Hello, World!"
void main() { IO.println("Hello, World!"); }
fun main() { println("Hello, World!") }
print("Hello, World!")
#include <stdio.h> int main() { printf("Hello, World!\n"); return 0; }
#include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; }
fn main() { println!("Hello, World!"); }
package main import "fmt" func main() { fmt.Println("Hello, World!") }
program hello print *, "Hello, World!" end program hello
println("Hello, World!")
with Ada.Text_IO; use Ada.Text_IO; procedure Hello is begin Put_Line("Hello, World!"); end Hello;
"Hello, World!
filter function in the language of your choice.
Answer: Filtering means to select those elements from a list that satisfy a given predicate. Usually, a filter operation creates a new list that contains only those elements, but it is also possible to filter in place, modifying the original list by dropping the elements not satisfying the predicate. Here is an example in JavaScript:
numbers.filter(n => n % 2 === 0)
numbers except that every value is cubed. Use broadcasting.
Answer: numbers .^ 3
Answer: Pragmatics encompasses the practical aspects of programming language usage, including readability, writability, efficiency, the contexts in which languages are used, issues in language design, implementation, and performance, and the trade-offs involved in choosing one language over another for specific tasks.
{+/x[&x!2]^2}
Answer: The expression is enclosed in curly braces, so it is a function. The parameter is x, because the first parameter to a function is K is always called x. Working from the inside out:
!2 maps the “mod 2” operation over the elements of x, returning a new array (which will contain 1s and 0s)& returns the indices where the 1s appear in x!2, that is, an array containing the indexes of the odd elements of x.[] selects the elements of x at the positions in &x!2.^2 squares each element of that new array.+/ sums the elements of that squared array.Thus, this K fragment is a function computes the sum of squares of its odd elements.
Here is a console session that demonstrates this:
a: 3 5 4 2 1 8 9 0 a!2 1 1 0 0 1 0 1 0 &a!2 0 1 4 6 a[&a!2] 3 5 1 9 a[&a!2]^2 9 25 1 81.0 +/a[&a!2]^2 116.0
Answer: Today, object-orientation is a programming paradigm in which objects encapsulate properties and dynamically-polymorphic methods and are organized into type hierarchies. Originally it referred to a system design in which objects communicated solely through messaging. Alan Kay, who coined the term, famously said: “OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.”
ᐊᐃᓐᖓᐃ? List the code point and name of each character that appears, in order. What is the meaning of the string, assuming its intended context?
Answer: I used Java for this!
jshell> "ᐊᐃᓐᖓᐃ".codePoints().forEach(c -> IO.println(String.format("U+%04X\t%c\t%s", c, c, Character.getName(c))))
U+140A ᐊ CANADIAN SYLLABICS A
U+1403 ᐃ CANADIAN SYLLABICS I
U+14D0 ᓐ CANADIAN SYLLABICS N
U+1593 ᖓ CANADIAN SYLLABICS NGA
U+1403 ᐃ CANADIAN SYLLABICS I
In Inuktitut, the phrase is a general greeting roughly translated as “Hello.”
Answer: Control flow describes activity within a single line of execution, while concurrency is about the coordination of multiple lines of execution.
Answer: A machine language is a sequence of numbers, each representing a machine instruction. An assembly language is an alphanumeric representation of these instructions, together with features such as named variables and labels, and directives that give some overall structure to a program.
Here is a simple example for the ARM 64 processor for a function that squares a 64-bit integer. The machine language (in hex) is:
00 7C 00 1B C0 03 5F D6
This corresponds to the assembly language:
square:
mul w0, w0, w0
ret
Answer: Here is the function in Mojo:
fn f(n: Int) -> Int: (3 * n + 1) if n % 2 == 0 else (4 * n - 3)
Answer: Verse was created at Epic Games and first released in 2023. It was created, as Gemini says, “to build the metaverse by providing a simple, powerful, and scalable tool for creating interactive 3D experiences within a decentralized, open economy, enabling developers to collaborate, monetize their creations, and integrate content and code seamlessly in shared, real-time environments.” The “functional-logic” paradigm, for which Verse touts itself as supporting, combines the declarative nature of logic programming with the higher-order functions and immutability of functional programming.