add demonstration

This commit is contained in:
2026-03-24 15:48:18 +03:00
parent 3da8851a64
commit 6b719a37e3

24
bin/demo Executable file
View 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