Skip to content

Instantly share code, notes, and snippets.

View KamilaBorowska's full-sized avatar

Kamila Borowska KamilaBorowska

View GitHub Profile
use std::result;
#[derive(Copy, Clone)]
pub enum Alignment {
Left,
Right,
Center,
}
pub type Result = result::Result<(), Error>;
Species Formes count
Venusaur 2
Charizard 3
Blastoise 2
Beedrill 2
Pidgeot 2
Rattata 2
Raticate 3
Pikachu 8
Raichu 2
.forty.two:
.string "42"
.globl main
main:
subq $8, %rsp
movl $.forty.two, %edi
call puts
xorl %eax, %eax
addq $8, %rsp
ret
import java.util.function.Function;
public class Currying {
public static void main(String[] args) {
Function<Integer, Function<Integer, Integer>> adder = x -> y -> x + y;
Function<Integer, Integer> addToTwo = adder.apply(2);
System.out.println(addToTwo.apply(4));
}
}
import Data.IORef
for init cond inc block = do
let loop = do
res <- cond
if res then
do
block
inc
loop
#[macro_use]
extern crate cpp;
cpp! {{
#include <numeric>
#include <vector>
}}
fn main() {
let y = 3;
import java.util.Arrays;
public class Sorting {
private final static int[] runLengths = new int[]{
76405736, 74830360, 1181532, 787688, 1575376, 2363064, 3938440, 6301504,
1181532, 393844, 15753760, 1575376, 787688, 393844, 1969220, 3150752, 1181532, 787688, 5513816, 3938440,
1181532, 787688, 1575376, 18116824, 1181532, 787688, 1575376, 2363064, 3938440, 787688, 26781392, 1181532,
787688, 1575376, 2363064, 393844, 4332284, 1181532, 787688, 1575376, 12209164, 1181532, 787688, 1575376,
2363064, 787688, 393844, 4726128, 1575376, 787688, 1969220, 76405758, 53168940, 1181532, 787688, 1575376,
2363064, 3938440, 1575376, 787688, 393844, 10633788, 1181532, 787688, 1575376, 2363064, 4332284, 1181532,
struct X {
int x[100];
};
X hi() {
return {0};
}
import java.util.List;
public class Main {
public static void main(String[] args) {
apply(List.of(5, 5.0));
}
static <T extends Number & Comparable<? extends U>, U extends Number & Comparable<? extends V>, V extends Number & Comparable<? extends W>, W extends Number & Comparable<?>> void apply(List<T> value) {
}
}

I'm surprised that everyone in this question claims that std::cout is way better than printf, even if the question just asked for differences. Now, there is a difference - std::cout is C++, and printf is C (however, you can use it in C++, just like almost anything else from C). Now, I'll be honest here; both printf and std::cout have their advantages.

Disclaimer: I'm more experienced with C than C++, so if there is a problem with my answer, feel free to edit or comment.

Real differences

Extensibility