ee.Array.reduce
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
با جمع کردن تمام مقادیر ورودی در امتداد هر محور مشخص شده در یک مقدار خروجی واحد که توسط کاهنده محاسبه می شود، یک کاهنده را به آرایه اعمال کنید.
خروجی همیشه ابعاد یکسانی با ورودی دارد و محورهای جداگانه به صورت زیر تحت تأثیر قرار می گیرند:
طول محورهای مشخص شده در پارامتر 'axes' به 1 کاهش می یابد (با اعمال کاهنده).
اگر کاهنده چندین ورودی یا چند خروجی داشته باشد، از محور مشخص شده در "fieldAxis" برای ارائه ورودی های کاهنده و ذخیره خروجی های کاهنده استفاده می شود.
تمام محورهای دیگر تحت تأثیر قرار نمی گیرند (کاهش مستقل انجام می شود).
استفاده | برمی گرداند | Array. reduce (reducer, axes, fieldAxis ) | آرایه |
استدلال | تایپ کنید | جزئیات | این: array | آرایه | آرایه. |
reducer | کاهنده | کاهنده برای اعمال. هر یک از خروجی های آن باید یک عدد باشد نه آرایه یا نوع دیگری. |
axes | فهرست کنید | فهرست محورهایی که باید کاهش داد. طول خروجی در تمام این محورها 1 خواهد بود. |
fieldAxis | عدد صحیح، پیش فرض: null | محوری که به عنوان فیلدهای ورودی و خروجی کاهنده استفاده می شود. تنها زمانی مورد نیاز است که کاهنده دارای چندین ورودی یا چند خروجی باشد، در این صورت محور باید طولی برابر با تعداد ورودی های کاهنده داشته باشد و در نتیجه طولی برابر با تعداد خروجی های کاهنده خواهد داشت. |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003e\u003ccode\u003eArray.reduce\u003c/code\u003e collapses input values along specified axes into single output values using a reducer function.\u003c/p\u003e\n"],["\u003cp\u003eThe output array retains the original input dimensionality, with specified axes reduced to length 1.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003efieldAxis\u003c/code\u003e is used when your reducer has multiple inputs or outputs, aligning with those fields.\u003c/p\u003e\n"],["\u003cp\u003eIndependent reductions are performed along all other axes not specified in the \u003ccode\u003eaxes\u003c/code\u003e parameter.\u003c/p\u003e\n"]]],[],null,["# ee.Array.reduce\n\nApply a reducer to an array by collapsing all the input values along each specified axis into a single output value computed by the reducer.\n\n\u003cbr /\u003e\n\nThe output always has the same dimensionality as the input, and the individual axes are affected as follows:\n\n- The axes specified in the 'axes' parameter have their length reduced to 1 (by applying the reducer).\n\n- If the reducer has multiple inputs or multiple outputs, the axis specified in 'fieldAxis' will be used to provide the reducer's inputs and store the reducer's outputs.\n\n- All other axes are unaffected (independent reductions are performed).\n\n| Usage | Returns |\n|----------------------------------------------|---------|\n| Array.reduce`(reducer, axes, `*fieldAxis*`)` | Array |\n\n| Argument | Type | Details |\n|---------------|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `array` | Array | The array. |\n| `reducer` | Reducer | The reducer to apply. Each of its outputs must be a number, not an array or other type. |\n| `axes` | List | The list of axes over which to reduce. The output will have a length of 1 in all these axes. |\n| `fieldAxis` | Integer, default: null | The axis to use as the reducer's input and output fields. Only required if the reducer has multiple inputs or multiple outputs, in which case the axis must have length equal to the number of reducer inputs, and in the result it will have length equal to the number of reducer outputs. |"]]