Language(言語コーパス) | Simulang言語 | 日本単位系を作った
simulationライブラリで純粋な関数式プログラミングをします
微分器 | 方程式的なプログラミング | 状態の手順的と関数的な表記の相互変換
VM を作った | CodeEditBox | Simulang言語の規格 | 連続と離散の統一
関東ブラウザ | CPUの回路図 | 4Dエンジン
こんな日本語の文字を考案した (IMEのダウンロード) | 人工言語
虫は宇宙人 | 人類の品種 | 言葉の起源 | 日本語は海豚語 | ウルトラマン
diablo2全スキル+21のチャーム | ダンジョンシージ2 | X3 TC 工場を買う
半光速度で宇宙旅行をする方法(超簡単です) | 日本単位系を作った(C#)
 1 2 3 4 5 ... 50
状態の手順的と関数的な表記の相互変換
0   関東の国王      2021年3月24日 水 1:26
追記
このあたりのことは今日やっと C#, F# で実装できました、ソースコードは後半にて

y = if s = 1 then f1(x) elif s = 2 then f2(x)
<==>
if s=1 then y=f1(x) elif s=2 then y=f2(x)

s' =  if s=1 and a then 2
       elif s=1 and b then 1
       elif s=2 and a then 1
       elif s=2 and c then 2
<==>
s' =  if s=1 and a then s'=2
       elif s=1 and b then s'=1
       elif s=2 and a then s'=1
       elif s=2 and c then s'=2

<==>

if s=1 then
  y=f1(x)
  if a then s'=2 elif b then s'=1
elif s=2 then
  y=f2(x)
  if a then s'=1 elif c then s'= 2

<==>

10 y = f1(x)
    if a then
20   y= f2(x)
        if a then goto 10 elif c then goto 20
    elif  b then
        goto 10                
---------------
1 IF a THEN
2 IF a THEN GOTO 1 ELIF c THEN GOTO 2
ELIF b THEN GOTO 1
y = if s = 1 then f1(x) elif s = 2 then f2(x)
---------------
switch s
case 1
   if a then s' = 2 elif b then s' = 1
case 2
   if a then s' = 1 elif c then s' = 2
y = if s = 1 then f1(x) elif s = 2 then f2(x)
----------------
s' = switch s case 1
       if a then 2 elif b then 1
   case 2
       if a then 1 elif c then 2
y = if s = 1 then f1(x) elif s = 2 then f2(x)

追記
上記の擬似コードをC#, F#で実装してみると:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Takaku;

namespace Simulation.StateX
{
   class CachedVarOfState
   {  
       private Func<object> FuncValue;
       private object Value;
       private bool Calculated;
       public CachedVarOfState(Func<object> funcValue)
       {
           FuncValue = funcValue;
           Calculated = false;
       }
       public object v()
       {
           if (Calculated)
               return Value;
           else
           {
               Calculated = true;
               return Value = FuncValue();
           }
       }
       public void Flush()
       {
           Calculated = false;
       }
   }

   interface IStateX
   {
       void Update();
       void Flush();
   }

   class ManagerX
   {
       public static ManagerX TheManagerX = new ManagerX();
       private LinkedList<IStateX> AllStateX = new LinkedList<IStateX>();
       public void Add(IStateX stateX)
       {
           AllStateX.AddLast(stateX);
       }
       public void Remove(IStateX stateX)
       {
           AllStateX.Remove(stateX);
       }
       public void Update()
       {
           foreach (IStateX i in AllStateX)
               i.Update();
       }
       public void Flush()
       {
           foreach (IStateX i in AllStateX)
               i.Flush();
       }
   }

   class StateX<S> : IStateX
   {
       public Dictionary<S, Dictionary<string, CachedVarOfState>> CachedVarsOfState = new Dictionary<S, Dictionary<string, CachedVarOfState>>();
       public Dictionary<S, List<Takaku.Tuple<Func<bool>, S>>> Jumps = new Dictionary<S, List<Takaku.Tuple<Func<bool>, S>>>();
       public S Current, Next;
       public StateX(S defaultValue)
       {
           Current = defaultValue;
           ManagerX.TheManagerX.Add(this);
       }
       void Remove()
       {
           ManagerX.TheManagerX.Remove(this);
       }
       public void Update()
       {
           foreach (Takaku.Tuple<Func<bool>, S> i in Jumps[Current])
           {
               if (i._1())
               {
                   Next = i._2;
                   return;
               }
           }

           Next = Current;
       }
       public void Flush()
       {
           Current = Next;

           foreach (KeyValuePair<S, Dictionary<string, CachedVarOfState>> i in CachedVarsOfState)
           {
               foreach (KeyValuePair<string, CachedVarOfState> j in i.Value)
               {
                   j.Value.Flush();
               }
           }
       }
       public object GetCachedVar(string nameCachedVar)
       {
           return CachedVarsOfState[Current][nameCachedVar].v();
       }
   }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Simulation.StateX;

namespace SimulationStateXCSharp
{
   public partial class Form1 : Form
   {
       bool Exit = false;

       StateX<byte> stateX = new StateX<byte>(1);
       int x1 = 1;
       double x2 = 2;
       bool a = false, b = false, c = false;

       public Form1()
       {
           InitializeComponent();
       }

       private void Form1_Load(object sender, EventArgs e)
       {
           stateX.CachedVarsOfState[1] = new Dictionary<string, CachedVarOfState>();
           stateX.CachedVarsOfState[1]["y1"] = new CachedVarOfState(() => x1 + 1);
           stateX.CachedVarsOfState[1]["y2"] = new CachedVarOfState(() => x2 * 2);

           stateX.CachedVarsOfState[2] = new Dictionary<string, CachedVarOfState>();
           stateX.CachedVarsOfState[2]["y1"] = new CachedVarOfState(() => x1 + 2);
           stateX.CachedVarsOfState[2]["y2"] = new CachedVarOfState(() => x2 * 3);

           stateX.Jumps[1] = new List<Takaku.Tuple<Func<bool>, byte>>();
           stateX.Jumps[1].Add(new Takaku.Tuple<Func<bool>, byte>(() => a, 2));
           stateX.Jumps[1].Add(new Takaku.Tuple<Func<bool>, byte>(() => b, 1));
           
           stateX.Jumps[2] = new List<Takaku.Tuple<Func<bool>, byte>>();
           stateX.Jumps[2].Add(new Takaku.Tuple<Func<bool>, byte>(() => a, 1));
           stateX.Jumps[2].Add(new Takaku.Tuple<Func<bool>, byte>(() => c, 2));
       }

       private void Form1_FormClosed(object sender, FormClosedEventArgs e)
       {
           Exit = true;
       }

       private void Form1_Shown(object sender, EventArgs e)
       {
           while (Exit == false)
           {
               ManagerX.TheManagerX.Update();

               ManagerX.TheManagerX.Flush();

               a = false;
               b = false;
               c = false;

               textBox1.Text = stateX.GetCachedVar("y1").ToString();
               textBox2.Text = stateX.GetCachedVar("y2").ToString();

               Application.DoEvents();
           }
       }

       private void button1_Click(object sender, EventArgs e)
       {
           a = true;
       }

       private void button2_Click(object sender, EventArgs e)
       {
           b = true;
       }

       private void button3_Click(object sender, EventArgs e)
       {
           c = true;
       }
   }
}

//F# の詳細 (http://fsharp.net)

namespace Simulation.StateX

   open System
   open System.Collections.Generic

   type CachedVarOfState = class
       val mutable FuncValue : unit -> Object
       [<DefaultValue>]
       val mutable Value : Object
       val mutable Calculated : bool
       new (funcValue : unit -> Object) =
           {
               FuncValue = funcValue;
               Calculated = false;
           }
       member x.v () =
           if x.Calculated then
               x.Value
           else
               x.Calculated <- true
               x.Value <- x.FuncValue ()
               x.Value
       member x.Flush () = x.Calculated <- false
   end

   type IStateX = interface
       abstract Update : unit -> unit
       abstract Flush : unit -> unit
   end

   module ManagerX =
       let AllStateX = new LinkedList<IStateX>()
       let Add (stateX : IStateX) = ignore (AllStateX.AddLast stateX)
       let Remove (stateX : IStateX) = ignore (AllStateX.Remove stateX)
       let Update () = for i in AllStateX do i.Update ()
       let Flush () = for i in AllStateX do i.Flush ()

   type StateX<'S when 'S : equality> = class
       interface IStateX with
           member x.Update () =
               for i in x.Jumps.[x.Current] do
                   if (fst i) () then
                       x.Next <- snd i
                       ()
               x.Next <- x.Current
           member x.Flush () =
               x.Current <- x.Next
               for i in x.CachedVarsOfState do
                   for j in i.Value do
                       j.Value.Flush ()
       end
       val mutable CachedVarsOfState : Dictionary<'S, Dictionary<string, CachedVarOfState>>
       val mutable Jumps : Dictionary<'S, List<(unit -> bool) * 'S>> // Dictionary<'S, List<Tuple<unit -> bool, 'S>>>
       val mutable Current : 'S
       [<DefaultValue>]
       val mutable Next : 'S
       new (defaultValue : 'S) as x =
           {
               Current = defaultValue;
               CachedVarsOfState = new Dictionary<'S, Dictionary<string, CachedVarOfState>>();
               Jumps = new Dictionary<'S, List<(unit -> bool) * 'S>>() // Dictionary<'S, List<Tuple<unit -> bool, 'S>>>()
           }
           then
               ManagerX.Add x
       member x.Remove () = ManagerX.Remove x
       member x.GetCachedVar(nameCachedVar : string) = x.CachedVarsOfState.[x.Current].[nameCachedVar].v ()
   end

   module Main =
       let main =
           let stateX = new StateX<byte>(byte 1)
           let x1 = 1;
           let x2 = 2.0
           let a = false
           let b = false
           let c = false;

           stateX.CachedVarsOfState.[byte 1] <- new Dictionary<string, CachedVarOfState>()
           stateX.CachedVarsOfState.[byte 1].["y1"] <- new CachedVarOfState(fun () -> (x1 + 1) :> Object)
           stateX.CachedVarsOfState.[byte 1].["y2"] <- new CachedVarOfState(fun () -> (x2 * 2.0) :> Object)

           stateX.CachedVarsOfState.[byte 2] <- new Dictionary<string, CachedVarOfState>()
           stateX.CachedVarsOfState.[byte 2].["y1"] <- new CachedVarOfState(fun () -> (x1 + 1) :> Object)
           stateX.CachedVarsOfState.[byte 2].["y2"] <- new CachedVarOfState(fun () -> (x2 * 3.0) :> Object)

           stateX.Jumps.[byte 1] <- new List<(unit -> bool) * byte>()
           stateX.Jumps.[byte 1].Add ((fun () -> a), byte 2)
           stateX.Jumps.[byte 1].Add ((fun () -> b), byte 1)

           stateX.Jumps.[byte 2] <- new List<(unit -> bool) * byte>()
           stateX.Jumps.[byte 2].Add ((fun () -> a), byte 1)
           stateX.Jumps.[byte 2].Add ((fun () -> c), byte 2)
           
           ()
この記事は 2021年10月12日 火 11:27 に作者によって編集されました
1   関東の国王      2021年7月14日 水 16:03
up
2   johnanz      2021年8月3日 火 23:40
3   Chauncey      2021年8月6日 金 4:27
How many would you like? http://www.vividtattoo.net/harga-crestor-rosuvastatin-20-mg-cazf apo rosuvastatin 5mg  The deal has come "not a moment too soon with the USTreasury expecting the debt ceiling to be breached on Oct. 17,potentially causing default in the weeks that follow if aninterest payment had been missed," analysts at ANZ said in anote. "In reality, politicians have done little more than kickthe can down the road three to four months."
4   Jimmi      2021年8月6日 金 4:27
Do you know what extension he's on? http://einwegmed-shop.com/duloxetine-30-mg-yan-etkileri-cazf duloxetine interactions bnf
 "We saw the House of Representatives stand with courage and listen to the American people," he said on the floor of the Senate. "I ask you to imagine a world in which Senate Republicans united to support House Republicans."
5   Deshawn      2021年8月6日 金 4:27
Could I make an appointment to see ? http://sandiegoquitsmokinghypnotherapy.com/acyclovir-generic-brand-cazf camber valacyclovir reviews  * Netflix Inc shares fell 5.2 percent to $248.38 inpremarket trade, a day after the online-entertainment firmreported that its quirky comedy "Arrested Development" lured newsubscribers in the second quarter, but not enough to impressinvestors.
6   Leroy      2021年8月6日 金 4:31
Incorrect PIN https://humbingethicals.com/lexapro-and-rem-sleep-rtqy advil sinus and lexapro  "This treaty will not diminish anyone's freedom, in fact the treaty recognizes the freedom of both individuals and states to obtain, possess and use arms for legitimate purposes," Kerry said after signing the treaty.
7   Arlen      2021年8月6日 金 4:31
We need someone with qualifications https://www.artom.lt/isotretinoin-rems-eosc tretinoin cream usp 0.1 benefits  "These data points will not mean much for the upcoming RBImonetary policy as their hands are tied at this stage and a lotwill depend on what comes out of the (Fed) meeting," said RupaRege Nitsure, chief economist at Bank of Baroda.
8   Landon      2021年8月6日 金 4:31
Not in at the moment https://gmh.com.tr/atenolol-25-mg-tablet-uses-in-tamil-vjcr atenolol dose for pvcs  Political wrangling has slowed the sale of company unitsAnsaldoEnergia, AsaldoBreda and Ansaldo STS. To datethe group has only agreed to sell its stake in aero engine partsmaker Avio for 260 million euros.
9   Josef      2021年8月6日 金 4:31
Who do you work for? https://bijouxenjade.com/paracetamol-and-ibuprofen-together-for-toothache-eosc paracetamol fosfato de codena antiinflamatrio  "They will need to at least maintain those inventories andthat swing in purchasing activity means that iron ore demand isactually a lot better than people are expecting."   (Reporting by Dominique Patton in BEIJING, Ruby Lian inSHANGHAI, Polly Yam in HONG KONG, Florence Tan in SINGAPORE;Editing by Ed Davies)
10   Fletcher      2021年8月6日 金 4:32
I'll put her on http://kik-cntu.kr.ua/cleocin-ovules-coupon-tezr cleocin dose for sinusitis  Perry had never lost an election during his 27-year political career and became a near-instant front-runner when he strapped on his signature cowboy boots and strode into the crowded race for the GOP presidential nomination in August 2011. A ferocious fundraiser who was buoyed by both tea party activists and mainstream Republicans, Perry had presided over a Texas economy that was booming and had such TV anchorman good looks he was dubbed by some “governor good hair.”
11   Morris      2021年8月6日 金 4:32
I've been cut off https://tnminter.com/buy-adalat-la-30-online-tezr buy adalat la 30 online  A World View ride would cost less than one-third of the $250,000 it will cost to fly on SpaceShipTwo. So far, about 650 people have put down deposits or paid for rides on the latter, which is undergoing testing at manufacturer Scaled Composites' facility in Mojave, California.
12   Kelly      2021年8月6日 金 4:32
How much were you paid in your last job? https://www.americas.cl/ibuprofene-constipation-vjcr ibuprofeno-cafeina 400mg/100mg precio  WASHINGTON — Attorney General Eric Holder will call Monday for major changes in the federal criminal justice system, including doing away with some mandatory minimum sentencing policies that have condemned scores of non-violent offenders to long prison terms and driven up the costs of incarceration.
13   Renaldo      2021年8月6日 金 4:32
Which year are you in? https://fyidelray.com/buy-clindamycin-phosphate-gel-d568 cleocin ovules generic  If your access is blocked, follow the directions on the email site help center. Once you again become the master of your email kingdom, invent a very sophisticated password, change your security questions and get creative in your answers because the hacker may well have nailed those questions correctly in the first place. Trust me -- you want them out of your life and not as permanent pen pals.
14   Clarence      2021年8月6日 金 4:33
A law firm https://huutoanland.com/diflucan-200-mg-torrinomedica-eosc diflucan sospensione orale sciacqui  Its portfolio includes some of the most popular U.S. malls and outlets, including Roosevelt Field Mall and Woodbury Common Premium Outlets in New York, the Forum Shops at Caesars Palace in Las Vegas, and the Galleria in Houston.
15   Isabel      2021年8月6日 金 4:33
magic story very thanks http://3g-vinaphone.vn/azelastine-hcl-nasal-solution-side-effects-cazf azelastine hydrochloride ophthalmic solution 0.05 pink eye  Roberts and Justices Antonin Scalia, Samuel Alito and Anthony Kennedy all questioned why a state's voters should not be able to change affirmative action policies, just as any other level of school or state government can. Justice Clarence Thomas' vote for the ban is virtually assured.
16   Coolman      2021年8月6日 金 4:35
What do you study? https://tnminter.com/is-there-a-prescription-zyrtec-tezr zyrtec generico  This was Avenue U, a block off Flatbush Ave. outside Kings Plaza, a shopping league of nations in the “new Brooklyn,” a diverse and progressive bastion, home of tolerant hipsters, liberal yuppies and mayoral candidate Bill de Blasio who raises biracial kids with his African-American wife.
17   Brice      2021年8月6日 金 4:35
I'm unemployed https://dolotgianguyen.com/can-buspar-make-ocd-worse-uebv can cymbalta and buspar be taken together  The 38-year-old Rodriguez made his big league season debut Aug. 5, the same day his suspension was announced. He had been sidelined since left hip surgery in January and his return was delayed by a leg injury in July.
18   Whitney      2021年8月6日 金 4:35
How much were you paid in your last job? https://www.ryanmcbain.com/forum/how-much-does-viagra-cost-at-pharmacy-209h buying viagra online advice  Naomi Watts looks every inch a princess as she channels the late Princess Diana in eerily perfect hair and makeup on the set of her new film, "Caught in Flight." Watts was spotted in full costume, wearing her hair short and blond in Diana's signature style and dressing up in evening wear and pearls to complete the look.
19   Angelo      2021年8月6日 金 4:35
I'm a housewife https://theolachi.com/clotrimazole-and-betamethasone-dipropionate-during-pregnancy-cazf salep clotrimazole cream  Thomson Reuters data through Tuesday morning showed thatanalysts expect S&P 500 companies' earnings to grow 2.9 percentin the quarter from a year ago, while revenue is forecast toincrease 1.5 percent over the same period.
 1 2 3 4 5 ... 50
ヒント: 「each」関数