### Rust: Read Lines from Stdin Source: https://gitlab.com/upstash/context7test-gitlab/-/blob/main/README.md Reads lines from standard input and echoes them back in Rust. This example highlights ownership-light IO usage. ```rust use std::io::{self, BufRead}; fn main(){ let stdin = io::stdin(); for line in stdin.lock().lines() { println!("{}", line.unwrap()); } } ``` -------------------------------- ### R Vector Squaring Source: https://gitlab.com/upstash/context7test-gitlab/-/blob/main/docs/guide.md A simple R example that creates a vector of numbers from 1 to 5 and then computes the square of each element. The result is then printed. This showcases basic vector operations in R. ```r nums <- 1:5 squares <- nums^2 print(squares) ``` -------------------------------- ### Swift Map and Filter on Arrays Source: https://gitlab.com/upstash/context7test-gitlab/-/blob/main/docs/api.md Demonstrates Swift's map and filter methods for concise array transformations. It filters an array of numbers to get even numbers and then doubles them. ```swift let nums = [1,2,3,4,5] let evensDoubled = nums.filter { $0 % 2 == 0 }.map { $0 * 2 } print(evensDoubled) ``` -------------------------------- ### Julia: List Comprehension for Cubes Source: https://gitlab.com/upstash/context7test-gitlab/-/blob/main/README.md Generates cubes of numbers in a given range using Julia's list comprehension syntax. This demonstrates concise data transformation. ```julia nums = 1:5 cubes = [n^3 for n in nums] println(cubes) ``` -------------------------------- ### Kotlin Data Class Copy Source: https://gitlab.com/upstash/context7test-gitlab/-/blob/main/docs/api.md Demonstrates Kotlin data classes and the copy method for immutable-style updates. It defines a User data class and shows how to create a modified copy of an instance. ```kotlin data class User(val id:Int, val name:String, val active:Boolean) fun main(){ val u1 = User(1, "Ada", true) val u2 = u1.copy(active = false) println(u2) } ``` -------------------------------- ### JavaScript Array Summation using Reduce Source: https://gitlab.com/upstash/context7test-gitlab/-/blob/main/docs/guide.md This snippet demonstrates summing the numbers in an array using JavaScript's reduce method. It showcases a concise, functional approach. The input is an array of numbers, and the output is their sum. ```javascript const nums = [1, 2, 3, 4, 5]; const total = nums.reduce((acc, n) => acc + n, 0); console.log(total); ``` -------------------------------- ### Scala List Filtering and Mapping Source: https://gitlab.com/upstash/context7test-gitlab/-/blob/main/docs/guide.md Demonstrates filtering and mapping a list using Scala's collection pipeline. It takes a list of numbers, filters for odd numbers, squares them, and prints the result. No external dependencies are required. ```scala object Main { def main(args: Array[String]): Unit = { val nums = List(1,2,3,4,5) val oddsSquared = nums.filter(_ % 2 == 1).map(n => n*n) println(oddsSquared) } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.