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
(1 + (2 + (3^((4 / 5) + (6 + ((7 + 8) / 9)))))) | |
(1 * ((((2^3) + 4) / 5)^(((6 + 7) / 8) + 9))) | |
((1 + (((2^3) * 4) * (5 | 6))) * (7 - (8 / 9))) | |
((1 + 2) + (3^((4 / 5) + (6 + ((7 + 8) / 9))))) | |
(((1^2) - 3) + ((4^(5 - ((6 - 7) / 8))) * 9)) | |
((1 / (2^((3^(4 / (5 + 6))) * (7 - 8))))^9) | |
((1^2) + ((3 / 4)^(5 - ((6 * (7 * 8)) / 9)))) | |
((1^2)+((3/4)^(5 - ((6*7)*(8/9))))) | |
(((1^2)*((3*4)/5))^(((6+7)/8)+9)) |
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
#[derive(Clone,PartialEq,Eq)] | |
24 enum Tile { | |
25 MeasuredWater, | |
26 Water, | |
27 Land, | |
28 Finalized(usize), | |
29 } | |
30 | |
31 | |
32 fn get_area(map: &mut Vec<Vec<Tile>>, startx: usize, starty: usize) -> usize { |
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
open System.Collections.Concurrent | |
open System.Threading.Tasks | |
open BenchmarkDotNet.Attributes | |
open BenchmarkDotNet.Configs | |
open BenchmarkDotNet.Running | |
open BenchmarkDotNet.Jobs | |
open System | |
// Learn more about F# at http://fsharp.org | |
// See the 'F# Tutorial' project for more help. |
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
open System.Collections.Concurrent | |
open System.Threading.Tasks | |
open BenchmarkDotNet.Attributes | |
open BenchmarkDotNet.Configs | |
open BenchmarkDotNet.Running | |
open BenchmarkDotNet.Jobs | |
open System | |
// Learn more about F# at http://fsharp.org | |
// See the 'F# Tutorial' project for more help. |
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
With no JIT that I am aware of (not jvm, not ryujit, not v8) can you make say, _mm256_sll_epi32 happen, at all. | |
With C++ I can call that with an intrinsic: `_mm_and_ps(x,y);` Now is it a pain, because to hit the various SIMD targets, I have | |
to write the SSE2 and AVX512 equivalents and detect which to use at runtime? Yes, it is a pain, though libraries like bSIMD exist | |
to remove that pain. | |
Also, no JIT that I am aware of can autovectorize something simple like a for loop adding up floats. The JVM doesn't do it, .NET doesn't | |
auto vectorize any user code ever. There isn't time to figure those out at runtime. | |
GCC, MSVCC, and LLVM, and Intel AOT compilers can all auto-vectorize simple cases like that, and Intel can sometimes do rather | |
amazing autovectorization. |
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
<script> | |
//All tests run repeatedly until numbers stabilize (jit warmup) | |
//Node 7.7.4 NODE_ENV = production - 42ms | |
//Firefox 52.0.1 32bit 250 to 280ms | |
//Firefox 52.0.1 64bit 210 to 250 ms | |
//Chrome 57.0.2987.110 (64-bit) 45ms | |
function testImperative(values) | |
{ |
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
public static void ForEach<T>(this T[] array, Action<T> lambda) | |
{ | |
foreach (var x in array) | |
{ | |
lambda.Invoke(x); | |
} | |
} | |
//use like |
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
// Compose a bunch of sprite sheets to make a uniqe npc as they | |
// come on screen. The sheets contain all the animation frames. | |
Texture2D shirtSheet = content.Load<Texture2D>(RandUtil.Index(shirtPaths)); | |
Texture2D pantSheet = content.Load<Texture2D>(RandUtil.Index(pantsPaths)); | |
Texture2D shoeSheet = content.Load<Texture2D>(RandUtil.Index(shoePaths)); | |
var renderTarget = new RenderTarget2D(PRPGame.graphics,baseSheet.Width,baseSheet.Height,false,SurfaceFormat.Color,DepthFormat.None,0,RenderTargetUsage.DiscardContents); | |
PRPGame.graphics.SetRenderTarget(renderTarget); | |
PRPGame.graphics.Clear(Color.Transparent); |
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
public static (T obj, float value) MinBy<T>(this T[] array,Func<T,float> lambda) | |
{ | |
float minValue = float.MaxValue; | |
T minT = default(T); | |
//note if you implement this for List<T>, don't use foreach, it is slower. Use a for loop. | |
foreach (var t in array) | |
{ | |
var value = lambda.Invoke(t); | |
if (value < minValue) | |
{ |
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
switch (SomeClass) | |
{ | |
case DerivedClassA a: | |
a.dostuff(); | |
break; | |
case DerivedClassB b: | |
b.dostuff(); | |
break; | |
} | |