add demonstration
This commit is contained in:
24
bin/demo
Executable file
24
bin/demo
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'bundler/setup'
|
||||||
|
require 'ruby_algebra'
|
||||||
|
|
||||||
|
puts 'RubyMaple © RubyMaple Creators, 2026. No rights reserved.'
|
||||||
|
|
||||||
|
loop do
|
||||||
|
puts 'Введите формулу (пустая строка для выхода): '
|
||||||
|
inp = $stdin.gets.chomp
|
||||||
|
exit if inp.empty?
|
||||||
|
begin
|
||||||
|
formula = RubyAlgebra::Parser.parse(inp)
|
||||||
|
rescue StandardError
|
||||||
|
puts 'Ошибка синтаксиса'
|
||||||
|
end
|
||||||
|
puts "Формула: #{formula}"
|
||||||
|
puts "Производная по x: #{formula.diff('x')}"
|
||||||
|
puts "Производная по y: #{formula.diff('y')}"
|
||||||
|
|
||||||
|
value = formula.evaluate
|
||||||
|
puts "Числовое значение: #{value}" unless value.nil?
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user