This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
viewer { | |
gists(first: 10) { | |
nodes { | |
id | |
isPublic | |
isFork | |
name | |
pushedAt | |
createdAt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// :collection Essential Go | |
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
// :show start | |
var wg sync.WaitGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// :glot | |
package main | |
import "fmt" | |
// :show start | |
func filterEvenValuesInPlace(a []int) []int { | |
// create a zero-length slice with the same underlying array | |
res := a[:0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// :show start | |
func filterEvenValues(a []int) []int { | |
var res []int | |
for _, el := range a { | |
if el%2 == 0 { | |
continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
constexpr long long factorial(int n) | |
{ | |
long long result = 1; | |
for (int i = 1; i <= n; ++i) { | |
result *= i; | |
} | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
constexpr long long factorial(long long n) | |
{ | |
if (n == 0) | |
return 1; | |
else | |
return n * factorial(n - 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
constexpr long long factorial(long long n) | |
{ | |
return (n == 0) ? 1 : n * factorial(n - 1); | |
} | |
int main() | |
{ | |
char test[factorial(3)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <type_traits> | |
template<long long n> | |
struct factorial : | |
std::integral_constant<long long, n * factorial<n - 1>::value> {}; | |
template<> | |
struct factorial<0> : | |
std::integral_constant<long long, 1> {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template<unsigned int n> | |
struct factorial | |
{ | |
enum | |
{ | |
value = n * factorial<n - 1>::value | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// :glot, no output | |
package main | |
// :show start | |
type MyStruct struct { | |
IntVal int | |
StringVal string | |
unexportedIntVal int | |
} |