arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2512.03492cs.CYcs.PL

在初级计算机科学课程中进行函数式Python编程

Functional Python Programming in Introductory Computer Science Courses

Rajshekhar Sunderraman

AI总结:

本文提出在初级Python编程课程中采用函数式编程方法,通过强制学生使用纯函数式子集学习不可变数据结构、纯函数和无状态编程等核心概念。

摘要:

函数式编程范式有着悠久的历史,其起源可以追溯到λ演算。近年来,纯函数式语言如Haskell已被证明在产生健壮的软件方面非常有效,这归功于不可变数据结构等函数式特性。使用不可变数据结构编程的优势也可以在非函数式语言如Python中获得。多年来,非函数式语言也引入了不可变数据结构以及推导和lambda表达式,并且可以在其中以纯函数式风格进行编程。在本文中,我们提出了一种在初级编程课程中采用的“最佳实践”理念,强制学生以Python的纯函数式子集学习和完成编程作业。通过这样做,学生可以学习函数式思想,如不可变性、无副作用的纯函数以及无状态编程。我们定义了Python的函数式子集,并通过小例子说明了最佳实践。我们强烈认为计算机科学的学生需要熟悉纯函数式编程,并论证这种教学可以在使用Python的初级编程课程中进行。

英文摘要:

The functional programming paradigm has a long and storied history, with its beginnings in the Lambda Calculus. In recent decades, pure functional languages such as Haskell have been shown to be highly effective in producing robust software due to immutable data structures, among other functional features. The advantages of programming with immutable data structures can also be had in non-functional languages such as Python. Over the years, non-functional languages have introduced immutable data structures as well as comprehension and lambda expressions, and it is possible to program in a purely functional style in them. In this paper, we present a ``best practice'' idea in introductory programming classes that forces students to learn and complete programming assignments in a purely functional subset of Python. By doing so, the student can learn functional ideas such as immutability, pure functions with no side effects, and stateless programming. We define a functional subset of Python and illustrate the best practice using small examples. We strongly feel that students in computing need familiarity with pure functional programming and argue that this can be taught in introductory programming courses that use Python.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑