Skip to content

Instantly share code, notes, and snippets.

@Mouq
Created November 17, 2014 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mouq/f36a4ccf9547947eec8e to your computer and use it in GitHub Desktop.
Save Mouq/f36a4ccf9547947eec8e to your computer and use it in GitHub Desktop.
use Math::Symbolic;
# PV=nRT
my $R = .08206;
my %h =
:P(EVAL prompt "P="),
:V(EVAL prompt "V="),
:N(EVAL prompt "N="),
:T(EVAL prompt "T=");
my ($undef, $err) = %h.keys.grep({ %h{$_} eq "" });
die if defined $err;
%h{$undef}:delete;
say my $eq = Math::Symbolic.new("P*V=N*$R*T").isolate($undef);
say $eq.evaluate(|%h);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment