الفرق بين المراجعتين ل"Ruby/Kernel/Complex"

من موسوعة حسوب
< Ruby‏ | Kernel
اذهب إلى التنقل اذهب إلى البحث
سطر 5: سطر 5:
 
يعيد التابع <code>Complex</code> ناتج التعبير <code>x + i * y</code>؛ حيث <code>i</code> هو الوحدة التخيلية العقدية.
 
يعيد التابع <code>Complex</code> ناتج التعبير <code>x + i * y</code>؛ حيث <code>i</code> هو الوحدة التخيلية العقدية.
  
قواعج الصياغة النصية:<syntaxhighlight lang="ruby">string form = extra spaces , complex , extra spaces ;
+
قواعد الصياغة النصية:<syntaxhighlight lang="ruby">string form = extra spaces , complex , extra spaces ;
 
complex = real part | [ sign ] , imaginary part
 
complex = real part | [ sign ] , imaginary part
 
         | real part , sign , imaginary part
 
         | real part , sign , imaginary part

مراجعة 00:08، 21 أكتوبر 2018

يعيد التابع Complex ناتج التعبير x + i * y؛ حيث i هو الوحدة التخيلية العقدية.

قواعد الصياغة النصية:

string form = extra spaces , complex , extra spaces ;
complex = real part | [ sign ] , imaginary part
        | real part , sign , imaginary part
        | rational , "@" , rational ;
real part = rational ;
imaginary part = imaginary unit | unsigned rational , imaginary unit ;
rational = [ sign ] , unsigned rational ;
unsigned rational = numerator | numerator , "/" , denominator ;
numerator = integer part | fractional part | integer part , fractional part ;
denominator = digits ;
integer part = digits ;
fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
imaginary unit = "i" | "I" | "j" | "J" ;
sign = "-" | "+" ;
digits = digit , { digit | "_" , digit };
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
extra spaces = ? \s* ? ;

البنية العامة

Complex(x[, y])    numeric

المعاملات

x‎

عدد يمثل الجزء الحقيقي من العدد العقدي

y‎

عدد يمثل الجزء التخيلي من العدد العقدي

القيمة المُعادة

يعيد التابع ناتج التعبير x + i * y.

أمثلة

مثال على استخدام التابع Complex‎:

Complex(1, 2)    #=> (1+2i)
Complex('1+2i')  #=> (1+2i)
Complex(nil)     #=> TypeError
Complex(1, nil)  #=> TypeError

انظر أيضا

مصادر