This file contains hidden or 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
Compile the C++ code creating a shared library (or shared object in UNIX) | |
$ clang++ TestJNI.cpp -o libTestJNI.so -fPIC -shared -std=c++11 -I$HOME/opt/java/include -I$HOME/opt/java/include/linux | |
Run the application | |
$ scala -save load.scala | |
dir = /home/archbox/opengl/jni/libTestJNI.so | |
Hello world java | |
i = 0 |
This file contains hidden or 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
% Author: Caio Rodrigues | |
% Objective: Test higher order functions and anonymous functions. | |
% | |
% Limitations: Doesn't support assignment in lambda function and also doens't support multiple lines. | |
% Other limitations are that functions cannot be stored in data structures or returned from functions. | |
% | |
octave:30> computeTable = @(xmin, dx, xmax, fn) [ (xmin:dx:xmax)' (fn(xmin:dx:xmax))'] | |
computeTable = | |
octave:15> computeTable(0.0, 0.1, 2.0, @(x)[2 * x + 1.0]) |
This file contains hidden or 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
$ octave --no-gui heatEquation2.m | |
Nx = 10 | |
Nt = 5 | |
dx = 0.10000 | |
dt = 0.0050000 | |
c = 1 | |
xmin = 0 | |
xmax = 1 | |
tmin = 0 | |
tmax = 1 |
This file contains hidden or 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 <iomanip> | |
#include <vector> | |
#include <chrono> | |
// External linkage without header file goes here. | |
// The symbols here are defined in *.o (Object files) | |
// or shared libraries. (*.so - UNIX) or (*.dll - Windows) | |
extern "C" { | |
// WARNING: This is the GFortran ABI which encodes symbols with underscore (_) |
This file contains hidden or 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
$ clang++ bindTest.cpp -std=c++11 -Wall -Wextra -g -o out.bin && ./out.bin | |
======== Test 1 ======== | |
bindTest.cpp:58: ; sum10(2.0) = 12 | |
bindTest.cpp:59: ; sum10(4.5) = 14.5 | |
bindTest.cpp:60: ; sum10(25.0) = 35 | |
======== Test 2 ======== | |
bindTest.cpp:66: ; vectorLenAsFunctionOfX(4.0) = 27.2213 | |
bindTest.cpp:67: ; std::bind(vectorLength, _1, 10.0, 25.0)(4.0) = 27.2213 | |
bindTest.cpp:68: ; vectorLenAsFunctionOfX(10.0) = 28.7228 |
This file contains hidden or 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
module ConstrainedTypes = | |
open System | |
// General hints on defining types with constraints or invariants | |
// | |
// Just as in C#, use a private constructor | |
// and expose "factory" methods that enforce the constraints | |
// | |
// In F#, only classes can have private constructors with public members. | |
// |
This file contains hidden or 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
(** | |
Talk given by Rizo Isrof | |
- https://pusher.com/sessions/meetup/the-realtime-guild/realtime-stream-processing-with-coroutines | |
- https://www.reddit.com/r/ocaml/comments/66pe0s/stream_processing_with_coroutines_from_c_to_ocaml/ | |
*) | |
# empty ;; | |
- : ('a, 'b, unit) pipe = Ready () | |
# |
This file contains hidden or 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
type DSL<'next> = | |
| Get of string * (string -> 'next) | |
| Set of string * string * 'next | |
| End | |
with static member fmap f = function | |
| Get (k, c) -> Get (k, f << c) | |
| Set (k, v, c) -> Set (k, v, f c) | |
| End -> End | |
type FreeDSL<'a> = |
This file contains hidden or 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
# lorenz.py | |
# 5 March 2016 | |
# | |
# Copyright 2016 Jason Milldrum | |
# | |
# Draw the Lorenz system in a GTK window | |
# See https://en.wikipedia.org/wiki/Lorenz_system | |
import math | |
import gi |
This file contains hidden or 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
/* | |
Ejemplos de código en C# | |
*/ | |
//32 for | |
using System; | |
public class Monaso{ |