Lightweight Enumeration

버전 1.0.0 (1.35 KB) 작성자: Shadow
Enumeration, i.e ForEach + Index. A small anonymous one liner, that allows for better readability of indices.
다운로드 수: 0
업데이트 날짜: 2024/6/13

라이선스 보기

% LIGHTWEIGHT_ENUMERATION by Shadow in 2024
% new command to improve readability of indexed for loops in code
enumerate = @(my_array) cell2mat(arrayfun(@(x,idx) struct("cargo",x,"idx",idx), my_array(:).', 1:numel(my_array(:).'),UniformOutput=false));
% SAMPLE CODE
clc
random_stuff = rand(1, 3)
column_list = (33:37).'
for outer = enumerate(column_list)
disp("Item Number " + string(outer.idx) +" contains the numer " + string(outer.cargo) + ".")
for inner = enumerate(random_stuff)
disp(" " + string(outer.idx) + ": random nr. " + string(inner.idx) + " is: " + string(inner.cargo) + ".")
end
end

인용 양식

Shadow (2024). Lightweight Enumeration (https://www.mathworks.com/matlabcentral/fileexchange/168011-lightweight-enumeration), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2024a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
태그 태그 추가

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0