Skip to content

Instantly share code, notes, and snippets.

@parsa
Forked from shahrzad/fib_test
Last active February 7, 2018 20:36
Show Gist options
  • Save parsa/6c2a601a6b402e24efba84aa3e9d0ce2 to your computer and use it in GitHub Desktop.
Save parsa/6c2a601a6b402e24efba84aa3e9d0ce2 to your computer and use it in GitHub Desktop.
// Copyright (c) 2018 Shahrzad Shirzad
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <phylanx/phylanx.hpp>
#include <hpx/hpx_main.hpp>
#include <iostream>
///////////////////////////////////////////////////////////////////////////////
char const* const tecode = R"(block(
define(fib_test, iterations,
block(
define(x, 1.0),
define(z, 0.0),
define(y, 1.0),
define(temp, 0.0),
define(step, 0),
while(
step < iterations,
block(
store(z, x + y),
store(temp, y),
store(y, z),
store(x, temp),
store(step, step + 1)
)
),
z
)
),
fib_test
))";
int main()
{
// Compile the given code
phylanx::execution_tree::compiler::function_list snippets;
auto fib_test = phylanx::execution_tree::compile(tecode, snippets);
auto const result = fib_test(static_cast<std::int64_t>(10));
return hpx::finalize();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment