TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Default Identity Value for Programming

2 pointsby farginayover 11 years ago

2 comments

npryceover 11 years ago
J has a similar feature: when applied to an empty array, &#x2F;+ returns 0 and &#x2F;* returns 1.<p>J doesn&#x27;t have user-defined types. In a language with user-defined types, you would probably have to declare which operations are monoids.
dvberkelover 11 years ago
I would concur with npryce. I your structure would adhere to the monoid interface and the default value could be cast automatically to the corresponding identity this will work. It wouldn&#x27;t even break mathematics