#ifndef TYPEASVALUE_EXAMPLE_TURING_SRC_STATE_H_ #define TYPEASVALUE_EXAMPLE_TURING_SRC_STATE_H_ #include "type.h" #include "list/list.h" #include "list/operation/higher/find.h" namespace machine { namespace state { namespace field { using ID = tav::Size<0>; using READ = tav::Size<1>; using WRITE = tav::Size<2>; using NEXT = tav::Size<3>; using MOVE = tav::Size<4>; } // (define (state_accessor state) // (lambda (field) // (nth field state))) template struct state_accessor { static_assert( tav::IsPair::value, "machine state is invalid" ); template using get = tav::Nth; }; // (define (state_predicate id read) // (lambda (state) // (and (= id (nth ID state)) // (= read (nth READ state))))) template < typename Id, typename Read > struct state_predicate { template using function = tav::And< tav::IsEqual>, tav::IsEqual> >; }; // (define (findState id read states) // (find (state_predicate id read) states)) template < typename Id, typename Read, typename States > using findState = tav::Find< state_predicate::template function, States >; // (define (transition states) // (lambda (state symbol) // (findState state symbol states))) template struct transition { template < typename State, typename Symbol > using state = state_accessor< findState >; }; } } #endif // TYPEASVALUE_EXAMPLE_TURING_SRC_STATE_H_