Skip to content

Instantly share code, notes, and snippets.

import java.util.Arrays;
public class ex3 {
public static void main(String args[]) {
var a = Arrays.asList(1, 2, 3, 5);
var result = a.stream().reduce(1, (s, i) -> s * i);
System.out.println(result);
}
import java.util.Arrays;
import java.util.stream.Collectors;
public class ex2 {
public static void main(String[] args) {
var a = Arrays.asList(1, 2, 3, 5);
var result = a.stream().filter(i -> i % 2 == 1);
System.out.println(
import java.util.Arrays;
import java.util.stream.Collectors;
public class ex1 {
public static void main(String args[]) {
// var a = Arrays.asList(1, 2, 3, 5);
var a = Arrays.asList(args)
.stream()
.map(i -> Integer.parseInt(i))
.collect(Collectors.toList());
# 1950 1960 1970 1980 1990 2000
# +----+--\-+----+---\+-\--+\---+\-\-+----+\--\+----+----+
# \ \ \ \ \ \ \ \ \\ \
# \ \ \ vi \ \ Emacs \ \\ \
# Lisp \ C \ C++ VB \Ruby C#
# Unix Microsoct \ STL
# Vim
@higaki
higaki / el.el
Last active January 13, 2020 02:03
(cons 1 (cons 2 (cons 3 (cons 5 ())))) ; => (1 2 3 5)
(list 1 2 3 5) ; => (1 2 3 5)
(quote (1 2 3 5)) ; => (1 2 3 5)
'(1 2 3 5) ; => (1 2 3 5)
(set 'a '(1 2 3 5)) ; => (1 2 3 5)
(setq a '(1 2 3 5)) ; => (1 2 3 5)
(let ((a '(1 2 3 5)))
(while a
@higaki
higaki / cpp.cpp
Last active January 13, 2020 01:55
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
ostream& operator<<(ostream& out, const pair<const string, int>& kv)
{
@higaki
higaki / cs.cs
Last active January 13, 2020 02:02
var a = new[]{1, 2, 3, 5};
a.GetType(); // => System.Int32[]
a[2]; // => 3
a[4]; // => インデックスが配列の境界外です。
foreach (var i in a) {
i.GetType(); // => Int32
Console.WriteLine(i);
}
var a = new List<int>{1, 2, 3, 5};
@higaki
higaki / frozen.rb
Last active November 20, 2019 03:52
# frozen_string_literal: true
RUBY_VERSION # => "2.7.0"
s = "Ruby"
t = "Ruby"
s == t # => true
s.equal? t # => true
@higaki
higaki / eql.rb
Last active November 21, 2019 06:54
RUBY_VERSION # => "2.7.0"
"a".hash # => -4127323257193555845
"b".hash # => -2092951289148142958
"foo".hash # => -4298047480057265190
"bar".hash # => 4242949873151017721
h = {"foo" => 0}
h["foo"] # => 0
@higaki
higaki / ===.rb
Last active November 20, 2019 03:59
RUBY_VERSION # => "2.7.0"
def foo?(str)
case str
when "foo" then true
else false
end
# "foo" === str
end